LCB-10: Make 10 Again
The Task
Scroll to read full problem statement
The Code
Claude Opus 4.6 with max-effort extended thinking. Exact outputs. Side by side.
Baseline
PASS869ch / 312simport sys
input = sys.stdin.readline
MOD = 998244353
def solve():
N = int(input())
A = list(map(int, input().split()))
dp = [0] * 1024
dp[1] = 1
for a in A:
inv_a = pow(a, MOD - 2, MOD)
new_dp = [0] * 1024
upper = min(a, 9)
cnt_gt10 = max(0, a - 10)
for S in range(1, 1024, 2):
if not dp[S]:
continue
prob = dp[S]
if cnt_gt10:
new_dp[S] = (new_dp[S] + prob * cnt_gt10 % MOD * inv_a) % MOD
for v in range(1, upper + 1):
shifted = S << v
if shifted & (1 << 10):
continue
new_S = (S | shifted) & 0x3FF
new_dp[new_S] = (new_dp[new_S] + prob * inv_a) % MOD
dp = new_dp
p_bad = sum(dp) % MOD
print((1 - p_bad) % MOD)
solve()Scroll to read full code
Augmented
PASS1034ch / 365simport sys
input = sys.stdin.readline
def solve():
MOD = 998244353
N = int(input())
A = list(map(int, input().split()))
FULL = (1 << 11) - 1
dp = [0] * (1 << 11)
dp[1] = 1 # bit 0 set: sum 0 achievable (empty subset)
for a in A:
new_dp = [0] * (1 << 11)
inv_a = pow(a, MOD - 2, MOD)
cap = min(a, 10)
no_change = a - cap # values > 10 don't affect achievable sums
for mask in range(1 << 11):
if dp[mask] == 0:
continue
p = dp[mask] * inv_a % MOD
if no_change > 0:
new_dp[mask] = (new_dp[mask] + p * no_change) % MOD
for v in range(1, cap + 1):
nm = mask | ((mask << v) & FULL)
new_dp[nm] = (new_dp[nm] + p) % MOD
dp = new_dp
ans = 0
for mask in range(1 << 11):
if mask & (1 << 10):
ans = (ans + dp[mask]) % MOD
print(ans)
solve()Scroll to read full code
Blind Evaluation
Independent evaluator. Randomized A/B labels. No knowledge of which solution used the injection.
Augmented 42, Baseline 36
| Dimension | Baseline | Augmented |
|---|---|---|
| Correctness | 9 | 10 |
| Efficiency | 9 | 7 |
| Code Structure | 6 | 8 |
| Readability | 5 | 8 |
| Robustness | 7 | 9 |
Blind Analysis
Both solutions solve a subset-sum-to-10 probability problem using bitmask DP. A bitmask of achievable subset sums is maintained, where bit j being set means "some subset of the dice processed so far has values summing to j." For each new die showing value v, the transition is new_mask = old_mask | (old_mask << v). Since adding positive values can only increase sums, anything above 10 can be safely discarded.
Blind Observation
The baseline reveals a solver who thinks in algebraic invariants first and code second. The decision to shrink the state space from 11 to 10 bits is not a micro-optimization — it's a conceptual reframing: "I don't need to track success, only failure." The odd-only iteration range(1, 1024, 2) is a secondary consequence of this framing, exploiting the bit-0 invariant that falls out of the structure.
Source: LiveCodeBench Hard benchmark. Full code outputs: baseline · augmented · runner script & methodology