From d429ee706adb8daa74c2541e93144115a8937fcb Mon Sep 17 00:00:00 2001 From: c14094071 Date: Fri, 23 Oct 2026 14:44:50 +0800 Subject: [PATCH] Fail triangle solutions that ignore reachability Every Mine Level Descent case gave the same answer to a correct bottom-up solution, to the sum of each level's minimum, and to a greedy walk that steps to the cheaper child, so both mistakes the problem's own pitfalls name passed all five cases. The two new cases put the cheapest chambers where the crew cannot reach them from each other, and each fails both wrong approaches while a correct solution still passes. Their labels join the tricky-case list so they stay. --- problem-bank/judges.json | 40 ++++++++++++++++++++++++++++++ tests/web/contract.rs | 2 ++ web/judges/mine-level-descent.json | 40 ++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+) diff --git a/problem-bank/judges.json b/problem-bank/judges.json index 530a4d4d..8e2da96e 100644 --- a/problem-bank/judges.json +++ b/problem-bank/judges.json @@ -13420,6 +13420,46 @@ ] ], "expected": -6 + }, + { + "label": "cheapest values not connected", + "input": [ + [ + [ + -1 + ], + [ + 2, + 3 + ], + [ + 1, + -1, + -3 + ] + ] + ], + "expected": -1 + }, + { + "label": "cheaper step misses the deep saving", + "input": [ + [ + [ + 1 + ], + [ + 2, + 3 + ], + [ + 4, + 5, + -10 + ] + ] + ], + "expected": -6 } ], "paramNames": [ diff --git a/tests/web/contract.rs b/tests/web/contract.rs index 4b3c6a5e..3dd13d97 100644 --- a/tests/web/contract.rs +++ b/tests/web/contract.rs @@ -686,6 +686,8 @@ fn static_problem_bank_and_judges_cover_each_problem() { ), ("merge-intervals", "unsorted"), ("valid-parentheses", "interleaved"), + ("triangle", "cheapest values not connected"), + ("triangle", "cheaper step misses the deep saving"), ] { let labels = judges[id]["cases"] .as_array() diff --git a/web/judges/mine-level-descent.json b/web/judges/mine-level-descent.json index 4d7b172c..0d7cc038 100644 --- a/web/judges/mine-level-descent.json +++ b/web/judges/mine-level-descent.json @@ -94,6 +94,46 @@ ] ], "expected": -6 + }, + { + "label": "cheapest values not connected", + "input": [ + [ + [ + -1 + ], + [ + 2, + 3 + ], + [ + 1, + -1, + -3 + ] + ] + ], + "expected": -1 + }, + { + "label": "cheaper step misses the deep saving", + "input": [ + [ + [ + 1 + ], + [ + 2, + 3 + ], + [ + 4, + 5, + -10 + ] + ] + ], + "expected": -6 } ], "paramNames": [