这是 2026-10-23 的上一版评测(LiveCodeBench 最新 35 题)。最新的阶梯评测见 首页。

题目 › arc195_c

Hamiltonian Pieces

AtCoder ARC 195 C 题 · 2025-03-23 · 困难

R 个红子(横竖走一步)和 B 个蓝子(斜走一步)摆上棋盘,使每个棋子一步能走到下一个、最后一个能走回第一个;判断能否做到并给出一种摆法。

查看原题

结果

Kimi K3.1 ProKimi

✓

通过

  • 官方测试 5/5(校验器)判题
  • 20.9k输出 token(含思考) ↓
  • 322 秒延迟 ↓
  • —最慢测试的 CPU 时间 ↓
  • —峰值内存 ↓
  • 24Pylint 问题 ↓
  • 7.04Pylint 得分 ↑
  • 13圈复杂度 ↓
  • 61.3可维护性指数 ↑
  • 85有效行
  • 1SonarQube 问题 ↓

DeepSeek-V4.1-FlashDS-Flash

✓

通过

  • 官方测试 5/5(校验器)判题
  • 22.4k输出 token(含思考) ↓
  • 120 秒延迟 ↓
  • —最慢测试的 CPU 时间 ↓
  • —峰值内存 ↓
  • 10Pylint 问题 ↓
  • 8.51Pylint 得分 ↑
  • 19圈复杂度 ↓
  • 57.8可维护性指数 ↑
  • 81有效行
  • 1SonarQube 问题 ↓

DeepSeek-V4-ProDS-Pro

✓

通过

  • 官方测试 5/5(校验器)判题
  • 64.1k输出 token(含思考) ↓
  • 453 秒延迟 ↓
  • —最慢测试的 CPU 时间 ↓
  • —峰值内存 ↓
  • 26Pylint 问题 ↓
  • 7.26Pylint 得分 ↑
  • 37圈复杂度 ↓
  • 41.4可维护性指数 ↑
  • 101有效行
  • 8SonarQube 问题 ↓

↑ 越大越好,↓ 越小越好,有效行只描述代码长短。CPU 时间与内存只统计能区分性能的题(最慢答案扣除进程启动后仍 ≥ 0.1 秒),括号内为相对最快者的倍数(≥ 2 时标出)。静态质量按 arXiv:2610.19167 的口径(见 原理)。判题方法见 原理 › 判题。

代码

Kimi K3.1 Pro · 119 行
import sys


def main():
    it = iter(map(int, sys.stdin.buffer.read().split()))
    T = next(it)
    output = []

    for _ in range(T):
        R = next(it)
        B = next(it)
        N = R + B

        # Every red move changes the parity of r+c, while every blue move
        # preserves it. Thus R must be even. If there are only blue pieces,
        # every move also changes the parity of r, so B must be even.
        if (R & 1) or (R == 0 and (B & 1)):
            output.append("No")
            continue

        colors = []
        rows = []
        cols = []
        nxt = []

        def add_node(color, r, c):
            idx = len(colors)
            colors.append(color)
            rows.append(r)
            cols.append(c)
            nxt.append(-1)
            return idx

        # Replace edge u -> v, where v = u + e, by
        # u -> u+f -> u+f+e -> v.
        # This inserts two pieces of the same color as u. Repeating the
        # operation on the new middle edge grows the construction without
        # collisions.
        def extend(u, e, f):
            v = nxt[u]
            ar = rows[u] + f[0]
            ac = cols[u] + f[1]
            a = add_node(colors[u], ar, ac)
            b = add_node(colors[u], ar + e[0], ac + e[1])
            nxt[u] = a
            nxt[a] = b
            nxt[b] = v
            return a

        start = -1

        if R == 0:
            # Base cycle for two blue pieces.
            start = add_node("B", 0, 0)
            other = add_node("B", 1, 1)
            nxt[start] = other
            nxt[other] = start

            u = start
            for _ in range((B - 2) // 2):
                u = extend(u, (1, 1), (1, -1))
        else:
            # Every mixed or all-red construction starts with two red pieces.
            start = add_node("R", 0, 0)   # A
            second = add_node("R", 1, 0)  # C
            blue_extension = -1
            base_blue = 0

            if B == 0:
                nxt[start] = second
                nxt[second] = start
            elif B & 1:
                # R,R,B triangle: (0,0) -> (1,0) -> (1,1) -> (0,0).
                last_blue = add_node("B", 1, 1)
                nxt[start] = second
                nxt[second] = last_blue
                nxt[last_blue] = start
                blue_extension = last_blue
                base_blue = 1
            else:
                # Base cycle with R=B=2.
                first_blue = add_node("B", 2, 0)
                last_blue = add_node("B", 1, 1)
                nxt[start] = second
                nxt[second] = first_blue
                nxt[first_blue] = last_blue
                nxt[last_blue] = start
                blue_extension = last_blue
                base_blue = 2

            # Add red pieces in pairs, growing downward from A -> C.
            u = start
            for _ in range((R - 2) // 2):
                u = extend(u, (1, 0), (0, -1))

            # Add blue pieces in pairs, growing upward/left from the
            # last blue piece toward A.
            if base_blue:
                u = blue_extension
                for _ in range((B - base_blue) // 2):
                    u = extend(u, (-1, -1), (-1, 1))

        # Translate the construction onto the positive board.
        row_shift = 1 - min(rows)
        col_shift = 1 - min(cols)

        output.append("Yes")
        cur = start
        for _ in range(N):
            output.append(
                f"{colors[cur]} {rows[cur] + row_shift} {cols[cur] + col_shift}"
            )
            cur = nxt[cur]

    sys.stdout.write("\n".join(output) + "\n")


if __name__ == "__main__":
    main()