arXiv:2510.22626cs.AI2025-10

让大模型编程时自动优化速度和内存,避免超时超内存。

SwiftSolve: A Self-Iterative, Complexity-Aware Multi-Agent Framework for Competitive Programming

  • 用多个智能体分工规划、编码、测试和分析复杂度,动态优化代码。
  • 首次尝试通过率61.5%,三次内解决率达80.8%,平均耗时仅12.7秒。
  • 适合想提升算法竞赛效率的开发者,尤其关注性能而非仅正确性。

仅正确不够:大模型生成的程序常通过单元测试但超出比赛的时间或内存限制。我们提出SwiftSolve,一种面向算法竞赛的复杂度感知多智能体框架,将算法规划与实测性能分析、复杂度引导修复相结合。将竞赛视为软件环境,各专用智能体扮演规划、编码、性能分析与复杂度评估角色。规划者提出算法草图;静态剪枝器剔除高风险方案;编码者生成符合ISO C++17标准的代码;性能分析器在固定输入规模下编译执行候选代码,记录运行时间和峰值内存;复杂度分析师通过拟合对数-对数增长曲线(s, R²)并辅以大模型判断复杂度类别,进而向规划者或编码者发送针对性修复指令。智能体间通过带类型与版本的JSON通信,控制器设定迭代上限与收益递减终止条件。在26个问题(16个时间复杂度题,10个Codeforces Div. 2题)上评估,运行于POSIX沙箱(2秒/256-512MB),SwiftSolve首次尝试通过率为61.54%(16/26),三次内解决率达80.77%,平均单次耗时从11.96秒增至12.66秒。整体运行成功率73.08%,均耗时12.40秒。失败主要源于资源约束,表明为效率问题非逻辑错误。相比Claude Opus 4,SwiftSolve在约2倍运行开销下(12.4秒 vs 6.8秒)提升运行成功率至73.1%(对比52.6%)。除正确性(pass@k)外,还报告效率指标(eff@k)、TLE/MLE发生率及复杂度拟合准确率,证明性能分析与复杂度引导重规划可有效降低低效问题并保持准确性。

原文摘要 · Abstract (English)

Correctness alone is insufficient: LLM-generated programs frequently satisfy unit tests while violating contest time or memory budgets. We present SwiftSolve, a complexity-aware multi-agent system for competitive programming that couples algorithmic planning with empirical profiling and complexity-guided repair. We frame competitive programming as a software environment where specialized agents act as programmers, each assuming roles such as planning, coding, profiling, and complexity analysis. A Planner proposes an algorithmic sketch; a deterministic Static Pruner filters high-risk plans; a Coder emits ISO C++17; a Profiler compiles and executes candidates on a fixed input-size schedule to record wall time and peak memory; and a Complexity Analyst fits log-log growth (s, R2) with an LLM fallback to assign a complexity class and dispatch targeted patches to either the Planner or Coder. Agents communicate via typed, versioned JSON; a controller enforces iteration caps and diminishing returns stopping. Evaluated on 26 problems (16 BigO, 10 Codeforces Div. 2) in a POSIX sandbox (2 s / 256-512 MB), SwiftSolve attains pass@1 = 61.54% (16/26) on the first attempt and Solved@<=3 = 80.77% with marginal latency change (mean 11.96 s to 12.66 s per attempt). Aggregate run-level success is 73.08% at 12.40 s mean. Failures are predominantly resource-bound, indicating inefficiency rather than logic errors. Against Claude Opus 4, SwiftSolve improves run-level success (73.1% vs 52.6%) at approximately 2x runtime overhead (12.4 s vs 6.8 s). Beyond correctness (pass@k), we report efficiency metrics (eff@k for runtime and memory, incidence of TLE or MLE, and complexity fit accuracy on BigO), demonstrating that profiling and complexity-guided replanning reduce inefficiency while preserving accuracy.

算法竞赛多智能体性能优化复杂度分析

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。