From 4de7fbe6ab52919568012497ac4cfcc5419c45cd Mon Sep 17 00:00:00 2001 From: xiawubing Date: Wed, 9 Sep 2026 22:50:06 -0500 Subject: [PATCH 1/2] Fix unjudgeable checkers for problems 11 and 210 - 11/chk.cc: the verdict was sprintf'd into a char[30] buffer although the formatted message is 41 characters, so every correct answer aborted with "buffer overflow detected" and only the three "-1" cases could score. Enlarge the buffer. Fixes #180. - 210/chk.cc: the per-base g/c/d/v read bounds were tighter than the shipped testdata (v up to 250 against readLong(0, 200)), so cases 4-9 FAILed on the input file before any contestant output was read. Loosen the bounds and document the observed ranges in the statement. Fixes #181. Re-judging the judge-recorded outputs of 32 archived agent runs (16 per problem) with the original checkers reproduces the official per-case scores exactly; with the fixed checkers, 52 previously crashing cases on 11 and 96 previously FAILing cases on 210 are judged, and no case that was judged before changes its score. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01AUL12r3HsmHBUTDGZxXFQr --- algorithmic/problems/11/chk.cc | 2 +- algorithmic/problems/210/chk.cc | 19 +++++++++++-------- algorithmic/problems/210/statement.txt | 1 + 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/algorithmic/problems/11/chk.cc b/algorithmic/problems/11/chk.cc index b6ca9bd95..2bf90fea4 100644 --- a/algorithmic/problems/11/chk.cc +++ b/algorithmic/problems/11/chk.cc @@ -77,7 +77,7 @@ int main(int argc, char **argv){ pnt = max(pnt, 0.0); unbounded_pnt = pnt; } - char mes[30]; + char mes[128]; sprintf(mes, "Ratio: %lf, RatioUnbounded: %lf", pnt, unbounded_pnt); quitp(pnt, "%s", mes); } diff --git a/algorithmic/problems/210/chk.cc b/algorithmic/problems/210/chk.cc index 28054f31b..56b0cf33f 100644 --- a/algorithmic/problems/210/chk.cc +++ b/algorithmic/problems/210/chk.cc @@ -89,11 +89,14 @@ int main(int argc, char* argv[]) { for (int i = 0; i < nb; i++) { int x = inf.readInt(0, n - 1); int y = inf.readInt(0, m - 1); - long long g = inf.readLong(0LL, 1000LL); - long long c = inf.readLong(0LL, 2000LL); + long long g = inf.readLong(0LL, 1000000000LL); + long long c = inf.readLong(0LL, 1000000000LL); // Blue-side defense/value are unused; allow 0 for compatibility with released datasets. - long long d = inf.readLong(0LL, 10LL); - long long v = inf.readLong(0LL, 200LL); + // The statement gives no ranges for g/c/d/v, so the bounds are deliberately loose: the + // released 4.in-9.in carry v up to 250 (c up to 2000, d up to 10), and a tight [0,200] + // here made the checker FAIL on its own input before reading any contestant output. + long long d = inf.readLong(0LL, 1000000000LL); + long long v = inf.readLong(0LL, 1000000000LL); (void)d; (void)v; blue[keyXY(x, y)] = BlueBase{g, c}; @@ -104,11 +107,11 @@ int main(int argc, char* argv[]) { for (int i = 0; i < nr; i++) { int x = inf.readInt(0, n - 1); int y = inf.readInt(0, m - 1); - long long g = inf.readLong(0LL, 1000LL); - long long c = inf.readLong(0LL, 2000LL); + long long g = inf.readLong(0LL, 1000000000LL); + long long c = inf.readLong(0LL, 1000000000LL); // Some released datasets may contain 0 defense/value; allow it and treat as non-contributing. - long long d = inf.readLong(0LL, 10LL); - long long v = inf.readLong(0LL, 200LL); + long long d = inf.readLong(0LL, 1000000000LL); + long long v = inf.readLong(0LL, 1000000000LL); (void)g; (void)c; red[keyXY(x, y)] = RedBase{d, v}; diff --git a/algorithmic/problems/210/statement.txt b/algorithmic/problems/210/statement.txt index df5654869..78e41fc57 100644 --- a/algorithmic/problems/210/statement.txt +++ b/algorithmic/problems/210/statement.txt @@ -93,6 +93,7 @@ Constraints (from released datasets): - `1 ≤ G ≤ 1000` - `1 ≤ C ≤ 1000` +- For bases: `0 ≤ g ≤ 1000`, `0 ≤ c ≤ 2000`, `0 ≤ d ≤ 10`, `0 ≤ v ≤ 250` --- From eb698097ad0f2b72268add2ed6003214938ba578 Mon Sep 17 00:00:00 2001 From: xiawubing Date: Thu, 10 Sep 2026 07:46:11 -0500 Subject: [PATCH 2/2] Fix the same buffer overflow in problem 22's checker algorithmic/problems/22/checker.cpp formats its verdict into char mes[30] with the same 41-character sprintf as problem 11, so every valid answer aborted with "buffer overflow detected". Enlarge the buffer. Reported by a reviewer on #184. A repository-wide search of every checker and interactor finds no other instance of this pattern. Re-judging the 40 judge-recorded outputs of 4 archived agent runs: the original checker aborts on all 40, the fixed one returns a verdict on all 40, and the build is clean under ASan/UBSan. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01AUL12r3HsmHBUTDGZxXFQr --- algorithmic/problems/22/checker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/algorithmic/problems/22/checker.cpp b/algorithmic/problems/22/checker.cpp index 79081e00a..89d4fc0ca 100644 --- a/algorithmic/problems/22/checker.cpp +++ b/algorithmic/problems/22/checker.cpp @@ -119,7 +119,7 @@ int main(int argc, char* argv[]) { double ratio = max(0.0, min(1.0, 1.0 * (5 * N - K) / 2 * N)); double unbounded_ratio = max(0.0, 1.0 * (5 * N - K) / 2 * N); - char mes[30]; + char mes[128]; sprintf(mes, "Ratio: %lf, RatioUnbounded: %lf", ratio, unbounded_ratio); quitp(ratio, "%s", mes); }