这是 2026-10-23 的上一版评测(LiveCodeBench 最新 35 题)。最新的阶梯评测见 首页。
结果
Kimi K3.1 ProKimi
✓
通过
- 函数调用,官方测试全部通过判题
- 20.5k输出 token(含思考) ↓
- 296 秒延迟 ↓
- 0.11 秒(2.2×)最慢测试的 CPU 时间 ↓
- 22 MB峰值内存 ↓
- 7Pylint 问题 ↓
- 8.60Pylint 得分 ↑
- 33圈复杂度 ↓
- 59.1可维护性指数 ↑
- 57有效行
- 2SonarQube 问题 ↓
DeepSeek-V4.1-FlashDS-Flash
✓
通过
- 函数调用,官方测试全部通过判题
- 8.9k输出 token(含思考) ↓
- 50 秒延迟 ↓
- 0.06 秒最慢测试的 CPU 时间 ↓
- 28 MB峰值内存 ↓
- 8Pylint 问题 ↓
- 8.73Pylint 得分 ↑
- 33圈复杂度 ↓
- 54.2可维护性指数 ↑
- 64有效行
- 2SonarQube 问题 ↓
DeepSeek-V4-ProDS-Pro
✓
通过
- 函数调用,官方测试全部通过判题
- 49.4k输出 token(含思考) ↓
- 368 秒延迟 ↓
- 0.05 秒(最快)最慢测试的 CPU 时间 ↓
- 22 MB峰值内存 ↓
- 10Pylint 问题 ↓
- 8.08Pylint 得分 ↑
- 35圈复杂度 ↓
- 58.6可维护性指数 ↑
- 54有效行
- 2SonarQube 问题 ↓
↑ 越大越好,↓ 越小越好,有效行只描述代码长短。CPU 时间与内存只统计能区分性能的题(最慢答案扣除进程启动后仍 ≥ 0.1 秒),括号内为相对最快者的倍数(≥ 2 时标出)。静态质量按 arXiv:2610.19167 的口径(见 原理)。判题方法见 原理 › 判题。
代码
Kimi K3.1 Pro · 79 行
from collections import deque from typing import List class Solution: def longestCommonPrefix(self, words: List[str], k: int) -> List[int]: n = len(words) if n - 1 < k: return [0] * n order = sorted(range(n), key=lambda i: words[i]) sorted_words = [words[i] for i in order] def lcp(a: str, b: str) -> int: limit = min(len(a), len(b)) i = 0 while i < limit and a[i] == b[i]: i += 1 return i # Values of all windows of k consecutive strings. window = [ lcp(sorted_words[i], sorted_words[i + k - 1]) for i in range(n - k + 1) ] # A new window after a deletion can come from a span of k + 1 # original strings with its deleted string inside the span. extended = [ lcp(sorted_words[i], sorted_words[i + k]) for i in range(n - k) ] m = len(window) prefix_max = [0] * (m + 1) for i, value in enumerate(window): prefix_max[i + 1] = max(prefix_max[i], value) suffix_max = [0] * (m + 1) for i in range(m - 1, -1, -1): suffix_max[i] = max(window[i], suffix_max[i + 1]) answer = [0] * n deque_indices = deque() added = 0 extended_len = len(extended) for pos in range(n): best = 0 # Original k-windows ending before the deleted position. right = pos - k if right >= 0: best = prefix_max[right + 1] # Original k-windows starting after the deleted position. left = pos + 1 if left < m: best = max(best, suffix_max[left]) # Sliding range maximum for newly created windows. range_right = min(pos - 1, extended_len - 1) while added <= range_right: value = extended[added] while (deque_indices and extended[deque_indices[-1]] <= value): deque_indices.pop() deque_indices.append(added) added += 1 range_left = max(0, pos - k + 1) while deque_indices and deque_indices[0] < range_left: deque_indices.popleft() if deque_indices: best = max(best, extended[deque_indices[0]]) answer[order[pos]] = best return answer
DeepSeek-V4.1-Flash · 88 行
from typing import List class Solution: def longestCommonPrefix(self, words: List[str], k: int) -> List[int]: n = len(words) if n - 1 < k: return [0] * n children = [{}] cnt = [0] depth = [0] terminals = [] for word in words: cnt[0] += 1 node = 0 for ch in word: nxt = children[node].get(ch) if nxt is None: nxt = len(children) children[node][ch] = nxt children.append({}) cnt.append(0) depth.append(depth[node] + 1) node = nxt cnt[node] += 1 terminals.append(node) node_count = len(children) always_best = 0 critical_nodes = [] for v in range(node_count): if cnt[v] >= k + 1: always_best = max(always_best, depth[v]) elif cnt[v] == k: critical_nodes.append(v) # Euler tour of the trie. tin = [0] * node_count tout = [0] * node_count timer = 0 stack = [(0, 0)] while stack: node, state = stack.pop() if state == 0: tin[node] = timer timer += 1 stack.append((node, 1)) for child in children[node].values(): stack.append((child, 0)) else: tout[node] = timer - 1 # Suffix maximum over Euler positions. at_tin = [-1] * node_count for v in critical_nodes: at_tin[tin[v]] = depth[v] suffix = [-1] * (node_count + 1) for i in range(node_count - 1, -1, -1): suffix[i] = max(suffix[i + 1], at_tin[i]) # Prefix maximum over tout positions. at_tout = [-1] * node_count for v in critical_nodes: at_tout[tout[v]] = max(at_tout[tout[v]], depth[v]) prefix = [-1] * (node_count + 1) for i in range(node_count): prefix[i + 1] = max(prefix[i], at_tout[i]) answer = [] for terminal in terminals: t = tin[terminal] # Critical nodes not being ancestors of this terminal. best_other = max(suffix[t + 1], prefix[t]) answer.append(max(always_best, best_other, 0)) return answer
DeepSeek-V4-Pro · 67 行
from typing import List class Solution: def longestCommonPrefix(self, words: List[str], k: int) -> List[int]: children = [dict()] cnt = [0] depth = [0] max_len = 0 # Build trie and count how many words have each prefix. for w in words: node = 0 for i, ch in enumerate(w, 1): nxt = children[node].get(ch) if nxt is None: nxt = len(children) children[node][ch] = nxt children.append({}) cnt.append(0) depth.append(i) node = nxt cnt[node] += 1 if i > max_len: max_len = i # For each depth, store the largest and second largest prefix counts. top1_cnt = [0] * (max_len + 1) top1_node = [-1] * (max_len + 1) top2_cnt = [0] * (max_len + 1) top2_node = [-1] * (max_len + 1) for node in range(1, len(cnt)): d = depth[node] c = cnt[node] if c > top1_cnt[d]: top2_cnt[d], top2_node[d] = top1_cnt[d], top1_node[d] top1_cnt[d], top1_node[d] = c, node elif c > top2_cnt[d]: top2_cnt[d], top2_node[d] = c, node # Original answer before removing any word. global_max = 0 for d in range(1, max_len + 1): if top1_cnt[d] >= k: global_max = d ans = [0] * len(words) for idx, w in enumerate(words): # If the removed word is too short to contain the global best prefix, # that prefix is unaffected. if len(w) < global_max: ans[idx] = global_max else: node = 0 best = 0 for d in range(1, global_max + 1): node = children[node][w[d - 1]] if top1_node[d] != node: if top1_cnt[d] >= k: best = d else: if top1_cnt[d] >= k + 1 or top2_cnt[d] >= k: best = d ans[idx] = best return ans