spot_img
HomeResearch & DevelopmentSwiftSolve: A Multi-Agent System for Efficient Competitive Programming Solutions

SwiftSolve: A Multi-Agent System for Efficient Competitive Programming Solutions

TLDR: SwiftSolve is a novel multi-agent AI framework designed to generate efficient and correct code for competitive programming. It features specialized agents (Planner, Static Pruner, Coder, Profiler, Complexity Analyst) that iteratively plan, code, profile, and refine solutions based on empirical performance and complexity analysis. The system significantly outperforms single-agent LLMs by focusing on optimizing for time and memory constraints, achieving an 80.77% success rate within three attempts on a diverse set of problems.

In the demanding world of competitive programming, simply writing correct code isn’t enough. Programs must also be highly efficient, adhering to strict time and memory limits. Large Language Models (LLMs) have shown great promise in generating code, but their outputs often struggle with these efficiency constraints, leading to ‘Time Limit Exceeded’ (TLE) or ‘Memory Limit Exceeded’ (MLE) errors.

A new framework called SwiftSolve addresses this critical gap by introducing a self-iterative, complexity-aware multi-agent system. Developed by researchers from Algoverse Research, UC Berkeley, and TU Darmstadt, SwiftSolve is designed to generate not just correct, but also highly efficient code for competitive programming challenges.

How SwiftSolve Works: A Team of Specialized Agents

SwiftSolve operates like a well-coordinated team of expert programmers, with each agent playing a distinct role:

  • The Planner Agent: This agent kicks off the process by taking a natural language problem description and proposing an initial algorithmic sketch. If a solution needs a major overhaul later, the Planner is called upon to devise a new strategy.

  • The Static Pruner: Acting as a quality control gate, this deterministic component quickly filters out obviously inefficient or risky plans proposed by the Planner, preventing wasted effort on code generation for unfeasible approaches.

  • The Coder Agent: Once a plan is approved, the Coder translates the algorithmic sketch into ISO C++17 code. It can also apply minor patches suggested by other agents to optimize existing code.

  • The Profiler Agent: This agent is crucial for empirical evaluation. It compiles and executes the generated code on a fixed schedule of input sizes, meticulously recording the wall-clock runtime and peak memory usage. It also identifies potential bottlenecks or ‘hotspots’ in the code.

  • The Complexity Analyst Agent: This is where SwiftSolve truly shines. The Analyst takes the profiling data and uses regression-based fitting to infer the time and memory complexity of the code (e.g., O(n), O(n^2)). It then compares this against contest constraints. If the code is inefficient, the Analyst dispatches targeted feedback – either a minor patch suggestion to the Coder or a request for an entirely new algorithmic approach to the Planner.

These agents communicate seamlessly using typed, versioned JSON messages, ensuring a structured and auditable workflow. A central controller manages the iteration process, enforcing limits on attempts and stopping when diminishing returns are observed or an efficient solution is found.

Also Read:

Impressive Results and Efficiency Gains

SwiftSolve was rigorously evaluated on 26 competitive programming problems, including 16 from BigO(Bench) and 10 from Codeforces Div. 2. Across 78 runs, the framework achieved a remarkable SOLVED@ ≤3 rate of 80.77%, meaning it successfully solved over 80% of problems within three attempts. Its initial attempt (PASS@1) success rate was 61.54%.

Crucially, this improvement came with only a marginal increase in latency, with the mean time per attempt rising slightly from 11.96 seconds to 12.66 seconds. The overall run-level success rate stood at 73.08% with an average run duration of 12.40 seconds.

A significant finding was that failures were predominantly due to resource limitations (TLE/MLE) rather than logical errors, highlighting SwiftSolve’s effectiveness in tackling the efficiency challenge. The iterative replanning mechanism proved highly effective, rescuing a substantial number of tasks that were not solved on the first attempt.

When compared against single-agent LLM baselines like Claude Opus 4 and GPT-4.1, SwiftSolve demonstrated substantially higher success rates on both datasets, especially on the more challenging Codeforces problems. This underscores the power of its multi-agent, complexity-aware approach in moving beyond mere correctness to deliver truly competitive solutions.

The research paper, titled “SwiftSolve: A Self-Iterative, Complexity-Aware Multi-Agent Framework for Competitive Programming,” provides a detailed look into the architecture and evaluation of this innovative system. You can read the full paper here.

SwiftSolve represents a significant step forward in automated code generation for competitive programming, shifting the focus from simply passing tests to generating code that is both correct and efficient under real-world resource constraints.

Karthik Mehta
Karthik Mehtahttps://blogs.edgentiq.com
Karthik Mehta is a data journalist known for his data-rich, insightful coverage of AI news and developments. Armed with a degree in Data Science from IIT Bombay and years of newsroom experience, Karthik merges storytelling with metrics to surface deeper narratives in AI-related events. His writing cuts through hype, revealing the real-world impact of Generative AI on industries, policy, and society. You can reach him out at: [email protected]

- Advertisement -

spot_img

Gen AI News and Updates

spot_img

- Advertisement -