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

题目 › abc400_d

Takahashi the Wall Breaker

AtCoder ABC 400 D 题 · 2025-04-05 · 中等

网格中可以走到相邻道路格,也可以向一个方向前踢,打通前方至多两格内的墙;求从起点到终点的最少前踢次数。

查看原题

结果

Kimi K3.1 ProKimi

✓

通过

  • 官方测试 44/44判题
  • 26.7k输出 token(含思考) ↓
  • 416 秒延迟 ↓
  • —最慢测试的 CPU 时间 ↓
  • —峰值内存 ↓
  • 4Pylint 问题 ↓
  • 9.29Pylint 得分 ↑
  • 14圈复杂度 ↓
  • 55.7可维护性指数 ↑
  • 56有效行
  • 1SonarQube 问题 ↓

DeepSeek-V4.1-FlashDS-Flash

✓

通过

  • 官方测试 44/44判题
  • 49.0k输出 token(含思考) ↓
  • 290 秒延迟 ↓
  • —最慢测试的 CPU 时间 ↓
  • —峰值内存 ↓
  • 16Pylint 问题 ↓
  • 8.32Pylint 得分 ↑
  • 44圈复杂度 ↓
  • 36.5可维护性指数 ↑
  • 95有效行
  • 1SonarQube 问题 ↓

DeepSeek-V4-ProDS-Pro

✓

通过

  • 官方测试 44/44判题
  • 63.9k输出 token(含思考) ↓
  • 544 秒延迟 ↓
  • —最慢测试的 CPU 时间 ↓
  • —峰值内存 ↓
  • 14Pylint 问题 ↓
  • 8.51Pylint 得分 ↑
  • 34圈复杂度 ↓
  • 39.2可维护性指数 ↑
  • 94有效行
  • 2SonarQube 问题 ↓

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

代码

Kimi K3.1 Pro · 76 行
import sys
from collections import deque


def main():
    data = sys.stdin.buffer.read().split()
    it = iter(data)

    h = int(next(it))
    w = int(next(it))
    grid = [next(it) for _ in range(h)]
    a = int(next(it))
    b = int(next(it))
    c = int(next(it))
    d = int(next(it))

    n = h * w
    start = (a - 1) * w + (b - 1)
    goal = (c - 1) * w + (d - 1)

    inf = n + 1
    dist = [inf] * n
    dist[start] = 0

    dq = deque([start])
    popleft = dq.popleft
    append = dq.append
    appendleft = dq.appendleft
    finished = bytearray(n)

    # Moving to an adjacent original road costs 0.
    # A kick makes the cells one and two steps away in its direction usable,
    # so reaching either of those cells can be represented by a cost-1 edge.
    directions = ((-1, 0, -w), (1, 0, w), (0, -1, -1), (0, 1, 1))

    while dq:
        v = popleft()
        if finished[v]:
            continue
        finished[v] = 1

        dv = dist[v]
        if v == goal:
            print(dv)
            return

        r, col = divmod(v, w)
        nd = dv + 1

        for dr, dc, step in directions:
            r1 = r + dr
            c1 = col + dc
            if 0 <= r1 < h and 0 <= c1 < w:
                u = v + step

                if grid[r1][c1] == 46 and dv < dist[u]:  # '.'
                    dist[u] = dv
                    appendleft(u)

                if nd < dist[u]:
                    dist[u] = nd
                    append(u)

                r2 = r1 + dr
                c2 = c1 + dc
                if 0 <= r2 < h and 0 <= c2 < w:
                    u += step
                    if nd < dist[u]:
                        dist[u] = nd
                        append(u)

    print(dist[goal])


if __name__ == "__main__":
    main()