Gemini 2.5 Pro
変動分析 · 2026年 第12週
Gemini 2.5 Pro 2026年 第12週 コード実行次元が 33.8 点上昇。主にDebug:DFS 环检测、异常处理链で得点
スコア比較
43.2
55.6
+12.4
| 次元 | 前回 | 今回 | 変動 |
|---|---|---|---|
| コード実行 | 22.8 | 56.6 | +33.8 |
| 知識総合 | 39.3 | 46 | +6.7 |
| 引用検証 | 60.2 | 81.2 | +21 |
| コストパフォーマンス | 21.4 | 31.6 | +10.2 |
| 安定性 | 54 | 31.2 | -22.8 |
| 可用性 | 100 | 99 | -1 |
失点 Top 5
浮点精度陷阱
66.7
0
-66.7
コード実行
exact_lines
STRICT
詳細証拠を展開
前回の回答
False
True
True
修正版代码:
```python
import math
# 推荐使用 math.isclose 进行浮点数比较
a = 0.1
b = 0.2
c = 0.3
if math.isclose(a + b, c):
print("a + b is close to c")
else:
print("a + b is NOT close to c")
```
今回の回答
False
True
True
```python
import math
# 修正版:使用 math.isclose 处理浮点数比较的边界条件
math.isclose(0.1 + 0.2, 0.3)
```
工程判断力:API限流处理
66.7
10
-56.7
知識総合
priority_order
STRICT
詳細証拠を展開
前回の回答
**第一步**
1. **服务降级**:立即暂停或禁用支付功能,对用户显示“系统繁忙,请稍后重试”或“支付渠道维护中”的友好提示。此举可立即阻止失败率继续攀升,防止产生更多错误订单和数据不一致问题。
2. **紧急沟通**:立刻联系第三方支付渠道的技术支持,告知对方情况,查询能否临时提高API调用频率限制。
3. **分析与取证**:检查服务器日志、监控图表,确认是哪些API调用触发了429错误,固定流量超预期的证据。
**第二步**
1. **评估与决策**:根据与支付渠道沟通的结果和对日志的分析,评估主渠道恢复所需的时间。
2. **加速测试**:在独立的测试环境中,用最快速度完成对备用支付渠道的核心支付、退款、对账流程的测试。
3. **制定预案**:如果主渠道无法在短时间内恢复,准备小流量(例如1%或5%)切换到备用支付渠道的方案,并密切监控其成功率和系统表现。
**暂不做**
* 在没有经过充分测试和风险评估的情况下,立即将全部流量切换到备用支付渠道。
今回の回答
**第一步**
联系第三方支付,紧急申请提高 API 调用频率限制。同时,立即在服务端实现支付降级或熔断机制,对新增支付请求返回“系统繁忙,请稍后重试”等提示,避免新用户继续失败,并保存所有失败订单的完整日志。
**第二步**
在测试环境中,模拟线上流量和压力,紧急完成对备用支付渠道的核心功能和性能测试。同时,深入分析流量来源,确认是正常业务增长、市场活动还是异常攻击。
**暂不做**
在未经验证的情况下,直接将全部或部分流量切换到备用支付渠道。
二分查找(左边界版)
20
0
-20
コード実行
python_unit_test
STRICT
詳細証拠を展開
前回の回答
```python
def binary_search(arr, target):
"""
在一个升序数组中查找目标值的第一个出现位置(左边界)。
Args:
arr (list[int]): 升序整数数组,可能包含重复元素。
target (int): 要查找的目标值。
Returns:
int: 如果找到目标值,返回其第一次出现的索引;否则返回 -1。
"""
left, right = 0, len(arr) - 1
first_pos = -1
while left <= right:
mid = left + (right - left) // 2
if arr[mid] == target:
first_pos = mid # 记录当前找到的位置
right = mid - 1 # 继续向左搜索,试图找到更早的出现位置
elif arr[mid] < target:
left = mid + 1
else: # arr[mid] > target
right = mid - 1
return first_pos
```
今回の回答
```python
def binary_search(arr, target):
"""
在升序数组 arr 中查找 target 的第一次出现(左边界)。
Args:
arr (list[int]): 一个升序排列的整数列表,可能包含重复元素。
target (int): 要查找的目标值。
Returns:
int: 如果 target 存在,返回其第一次出现的索引;否则返回 -1。
"""
left, right = 0, len(arr) - 1
result = -1
while left <= right:
mid = left + (right - left) // 2
if arr[mid] >= target:
if arr[mid] == target:
result = mid
right = mid - 1
else: # arr[mid] < target
left = mid + 1
return result
```
并查集
20
0
-20
コード実行
python_unit_test
STRICT
詳細証拠を展開
前回の回答
```python
class UnionFind:
"""
并查集类,支持路径压缩和按大小合并。
元素可以是任意可哈希对象。
"""
def __init__(self):
self.parent = {}
self.size = {}
def find(self, x):
"""查找元素x的根节点,并进行路径压缩。"""
if x not in self.parent:
self.parent[x] = x
self.size[x] = 1
return x
# 路径压缩
if self.parent[x] != x:
self.parent[x] = self.find(self.parent[x])
return self.parent[x]
def union(self, a, b):
"""合并元素a和b所在的集合,按大小合并。"""
root_a = self.find(a)
root_b = self.find(b)
if root_a == root_b:
return False
# 按大小合并:将小集合合并到大集合
if self.size[root_a] < self.size[root_b]:
self.parent[root_a] = root_b
self.size[root_b] += self.size[r...
今回の回答
```python
class UnionFind:
"""
并查集类,支持路径压缩和按大小合并。
元素可以是任意可哈希对象。
"""
def __init__(self):
"""
初始化 parent 字典和 size 字典。
parent[i] 表示元素 i 的父节点。
size[i] 表示以 i 为根的集合的大小(只对根节点有效)。
"""
self.parent = {}
self.size = {}
def find(self, x):
"""
查找元素 x 所在集合的根节点。
同时进行路径压缩。
"""
if x not in self.parent:
self.parent[x] = x
self.size[x] = 1
return x
# 路径压缩:在查找根节点的同时,将路径上的所有节点直接指向根节点。
root = x
while root != self.parent[root]:
root = self.parent[root]
# 将路径上的节点直接连接到根节点
while x != root:
old_parent = self.parent[x]
self.parent[x] = root
x = old_parent
...
代码输出:闭包
10
0
-10
コード実行
exact_lines
STRICT
詳細証拠を展開
前回の回答
[2, 2, 2]
今回の回答
[2, 2, 2]
得点 Top 5
Debug:DFS 环检测
10
95
+85
コード実行
diff_patch_unit_test
STRICT
詳細証拠を展開
前回の回答
```python
def has_cycle(graph):
visiting = set() # 存储当前递归栈中的节点
visited = set() # 存储已完全访问过的节点
def dfs(node):
# 如果节点在当前递归栈中,说明存在环
if node in visiting:
return True
# 如果节点已完全访问过,说明其下游无环,跳过
if node in visited:
return False
visiting.add(node)
for neighbor in graph.get(node, []):
if dfs(neighbor):
return True
# 节点的所有邻居都已访问完,将其从递归栈中移除,并加入已访问集合
visiting.remove(node)
visited.add(node)
return False
# 遍历图中所有节点,以处理非连通图的情况
for n in list(graph):
if n not in visited:
if dfs(n):
return True
return False
```
今回の回答
```python
def has_cycle(graph):
"""
判断有向图是否有环。
Args:
graph: 图的邻接表表示,格式为 {node: [neighbor1, neighbor2, ...]}
Returns:
bool: 如果图中存在环,返回 True,否则返回 False。
"""
visiting = set() # 存放当前递归栈中的节点 (灰色节点)
visited = set() # 存放已完全访问过的节点 (黑色节点)
def dfs(node):
# 如果节点在当前递归栈中,说明遇到了反向边,存在环
if node in visiting:
return True
# 如果节点已经完全访问过,说明从该节点出发的路径无环,直接返回
if node in visited:
return False
# 将节点加入当前递归栈
visiting.add(node)
# 遍历邻接节点
for neighbor in graph.get(node, []):
if dfs(neighbor):
return True
# 当前节点的所有邻接节点都访问完毕,将其从递归栈中移除
visiting.remove(node)
# 标记为已完全访问
visited.add(node)
return False
# 遍历图中所有节...
异常处理链
10
90
+80
コード実行
python_unit_test
STRICT
詳細証拠を展開
前回の回答
```python
import json
import logging
def load_and_apply(path):
"""
依次调用 read_config, parse_config, apply_config 并处理异常。
"""
try:
text = read_config(path)
config = parse_config(text)
apply_config(config)
except FileNotFoundError as e:
logging.error(f"配置文件读取失败: {e}")
return False
except json.JSONDecodeError as e:
logging.error(f"配置文件解析错误: {e}")
return False
except ValueError as e:
logging.error(f"配置应用失败: {e}")
return False
else:
return True
finally:
print("配置加载流程结束")
```
今回の回答
```python
import json
import logging
def load_and_apply(path: str) -> bool:
"""
加载并应用配置文件,处理可能发生的异常。
"""
try:
text = read_config(path)
config = parse_config(text)
apply_config(config)
except FileNotFoundError:
logging.error(f"配置文件未找到: {path}")
return False
except json.JSONDecodeError:
logging.error("配置文件格式错误,无法解析")
return False
except ValueError as e:
logging.error(f"应用配置失败: {e}")
return False
else:
return True
finally:
print("配置加载流程结束")
```
二叉树序列化(稳定格式版)
10
85
+75
コード実行
python_unit_test
STRICT
詳細証拠を展開
前回の回答
```python
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
def serialize(root: TreeNode) -> str:
"""Encodes a tree to a single string.
"""
if not root:
return "null"
res = []
def dfs(node):
if not node:
res.append("null")
return
res.append(str(node.val))
dfs(node.left)
dfs(node.right)
dfs(root)
return ",".join(res)
def deserialize(data: str) -> TreeNode:
"""Decodes your encoded data to tree.
"""
if not data or data == "null":
return None
nodes = data.split(',')
# Using an iterator on the list is a clean way to consume elements
it = iter(nodes)
def build_tree():
va...
今回の回答
```python
class TreeNode:
"""Definition for a binary tree node."""
def __init__(self, x):
self.val = x
self.left = None
self.right = None
def serialize(root: TreeNode) -> str:
"""Encodes a tree to a single string.
:type root: TreeNode
:rtype: str
"""
if not root:
return "null"
res = []
def preorder(node):
if not node:
res.append("null")
return
res.append(str(node.val))
preorder(node.left)
preorder(node.right)
preorder(root)
return ",".join(res)
def deserialize(data: str) -> TreeNode:
"""Decodes your encoded data to tree.
:type data: str
:rtype: TreeNode
"""
if not data or data == "null":
return None
vals = it...
贪心:活动选择(返回方案)
20
95
+75
コード実行
python_unit_test
STRICT
詳細証拠を展開
前回の回答
```python
def max_activities(activities):
"""
Selects the maximum number of non-overlapping activities.
Args:
activities: A list of tuples, where each tuple is (start_time, end_time).
Returns:
A list of selected activity tuples that maximizes the count and has the
lexicographically smallest end times in case of ties.
"""
if not activities:
return []
# Sort activities primarily by their end time, and secondarily by their start time.
# This ensures we always consider the activity that finishes earliest,
# leading to a lexicographically minimal sequence of end times.
sorted_activities = sorted(activities, key=lambda x: (x[1], x[0]))
# The first activity in the sorted list is always selected.
result = [sorted_a...
今回の回答
```python
def max_activities(activities):
if not activities:
return []
# Sort activities by their end time.
# This greedy choice is optimal for maximizing the number of activities
# and also ensures the lexicographically smallest sequence of end times.
sorted_activities = sorted(activities, key=lambda x: x[1])
result = []
last_end_time = -float('inf')
for start, end in sorted_activities:
if start >= last_end_time:
result.append((start, end))
last_end_time = end
return result
```
位运算:判断2的幂与 bit count
20
95
+75
コード実行
python_unit_test
STRICT
詳細証拠を展開
前回の回答
**代码:**
```python
def is_power_of_2(n):
return n > 0 and (n & (n - 1)) == 0
def count_bits(n):
return bin(n).count('1')
print(is_power_of_2(0))
print(is_power_of_2(8))
print(is_power_of_2(12))
print(count_bits(15))
```
**输出:**
```
False
True
False
4
```
今回の回答
**代码:**
```python
def is_power_of_2(n):
"""使用位运算判断正整数 n 是否是 2 的幂"""
return n > 0 and (n & (n - 1) == 0)
def count_bits(n):
"""返回 n 的二进制表示中 1 的个数"""
return bin(n).count('1')
print(is_power_of_2(0))
print(is_power_of_2(8))
print(is_power_of_2(12))
print(count_bits(15))
```
**输出:**
```
False
True
False
4
```