v2: add 216 optimize tasks / 77 families (Tao constants, AlphaEvolve, Leaps in Bounds, FrontierShift, FrontierCO MDS, ALE-Bench, FrontierCS, EdgeBench)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- LICENSE.md +5 -3
- README.md +47 -7
- data/optimize.parquet +2 -2
- families.csv +220 -143
- graders/ae_p14_hausdorff_young/check.py +42 -0
- graders/ae_p1_ff_nikodym_2d/check.py +57 -0
- graders/ae_p33_thomson/check.py +25 -0
- graders/ae_p35_hexagons_in_hexagon/check.py +43 -0
- graders/ae_p40_erdos_discrepancy_c3/check.py +27 -0
- graders/ae_p56_szemeredi_trotter/check.py +45 -0
- graders/ae_p57_rudin_l4/check.py +46 -0
- graders/ale_ahc002/check.py +57 -0
- graders/ale_ahc004/check.py +61 -0
- graders/ale_ahc009/check.py +82 -0
- graders/ale_ahc010/check.py +86 -0
- graders/ale_ahc011/check.py +96 -0
- graders/ale_ahc014/check.py +127 -0
- graders/ale_ahc017/check.py +89 -0
- graders/ale_ahc019/check.py +143 -0
- graders/ale_ahc021/check.py +76 -0
- graders/ale_ahc024/check.py +106 -0
- graders/ale_ahc026/check.py +80 -0
- graders/ale_ahc032/check.py +71 -0
- graders/ale_ahc038/check.py +140 -0
- graders/ale_ahc039/check.py +102 -0
- graders/ale_ahc041/check.py +80 -0
- graders/ale_ahc042/check.py +72 -0
- graders/ale_ahc044/check.py +60 -0
- graders/ale_ahc046/check.py +83 -0
- graders/edge_apple_incremental/check.py +67 -0
- graders/edge_grid_turing_robot/check.py +114 -0
- graders/fco_mds/check.py +31 -0
- graders/fcs_beacon/check.py +48 -0
- graders/fcs_digit_grid/check.py +68 -0
- graders/fcs_gcd_chain/check.py +50 -0
- graders/fcs_inc_subseq_perm/check.py +70 -0
- graders/fcs_inverse_paths/check.py +50 -0
- graders/fcs_lis_lds_split/check.py +44 -0
- graders/fcs_max3sat/check.py +25 -0
- graders/fcs_maxcut/check.py +18 -0
- graders/fcs_mult_partial_sums/check.py +51 -0
- graders/fcs_no_rectangle/check.py +61 -0
- graders/fcs_prime_retune/check.py +92 -0
- graders/fcs_shortcut3hop/check.py +33 -0
- graders/fcs_swap_shift/check.py +24 -0
- graders/fcs_xor_sidon/check.py +52 -0
- graders/fsh_abc_quality/check.py +57 -0
- graders/fsh_boolean_nonlinearity_9/check.py +25 -0
- graders/fsh_cramer_gap_ratio/check.py +31 -0
- graders/fsh_lwc_1280/check.py +30 -0
LICENSE.md
CHANGED
|
@@ -2,8 +2,10 @@
|
|
| 2 |
|
| 3 |
This collection repackages tasks from several sources. Each row's `license` column gives the license of its source:
|
| 4 |
|
| 5 |
-
- MIT: RLVE-Gym, NPPC, EinsteinArena (platform and baselines)
|
| 6 |
-
- CC-BY-4.0: MathConstraint; AlphaEvolve repository of problems (materials)
|
| 7 |
-
- Apache-2.0: Reasoning Gym, FunSearch, AlphaEvolve repository of problems (code), Finch / Evolution Fine-Tuning (code)
|
|
|
|
|
|
|
| 8 |
|
| 9 |
Please attribute the original authors when using the corresponding tasks.
|
|
|
|
| 2 |
|
| 3 |
This collection repackages tasks from several sources. Each row's `license` column gives the license of its source:
|
| 4 |
|
| 5 |
+
- MIT: RLVE-Gym, NPPC, EinsteinArena (platform and baselines), Leaps in Bounds (D. Munro), FrontierCO, FrontierCS
|
| 6 |
+
- CC-BY-4.0: MathConstraint; AlphaEvolve repository of problems (materials); EdgeBench (task directories; the underlying AtCoder problem statements remain © AtCoder)
|
| 7 |
+
- Apache-2.0: Reasoning Gym, FunSearch, AlphaEvolve repository of problems (code), Finch / Evolution Fine-Tuning (code), Optimization Constants in Mathematics (T. Tao, D. Davis, P. Ivanisvili et al.)
|
| 8 |
+
- **CC-BY-ND-4.0 (restricted): ALE-Bench (Sakana AI; AtCoder Heuristic Contest problems).** No derivatives: statements are reproduced verbatim; do not redistribute modified versions of these tasks without checking compatibility. Tagged `license_restricted`.
|
| 9 |
+
- **unknown: FrontierShift open problems (AItonomy Foundation).** The public registry states no license and its repository is not public. Tagged `license_unknown`.
|
| 10 |
|
| 11 |
Please attribute the original authors when using the corresponding tasks.
|
README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
---
|
| 2 |
license: other
|
| 3 |
-
license_name: mixed
|
| 4 |
license_link: LICENSE.md
|
| 5 |
configs:
|
| 6 |
- config_name: construct
|
|
@@ -19,14 +19,14 @@ size_categories:
|
|
| 19 |
|
| 20 |
# MathConstructOptimize-Envs
|
| 21 |
|
| 22 |
-
**3,
|
| 23 |
|
| 24 |
Most math RL data asks for a final number. Here the model has to produce the object itself: a colouring, a design, a counterexample, a point configuration, a polynomial. The checker accepts **any** valid object, not a stored answer. The collection has two subsets:
|
| 25 |
|
| 26 |
| subset | what the model does | reward | families | tasks |
|
| 27 |
|---|---|---|---|---|
|
| 28 |
| `construct` | produce any object satisfying stated conditions (a witness) | 1 if valid, else 0 | 80 | 3,464 |
|
| 29 |
-
| `optimize` | produce a valid object with the best objective it can (extremal constructions, bound improvement) | 0 if invalid; otherwise 0.1 + 0.9 × progress from a trivial baseline to the best known value |
|
| 30 |
|
| 31 |
The runnable sandboxed version (one [Harbor](https://github.com/laude-institute/harbor) task directory per row) is in
|
| 32 |
[`amphora/MathConstructOptimize-Envs-harbor`](https://huggingface.co/datasets/amphora/MathConstructOptimize-Envs-harbor).
|
|
@@ -41,12 +41,19 @@ Tasks are converted from existing generator suites and research-problem reposito
|
|
| 41 |
| [MathConstraint](https://github.com/vireshpati/Math-Constraint) | construct | competition | 33 | 875 |
|
| 42 |
| [NPPC](https://github.com/SMU-DIGA/nppc) | construct | competition | 8 | 480 |
|
| 43 |
| [Reasoning Gym](https://github.com/open-thought/reasoning-gym) | construct | competition | 3 | 180 |
|
| 44 |
-
| [AlphaEvolve repository of problems](https://github.com/google-deepmind/alphaevolve_repository_of_problems) | construct + optimize | research (mostly) |
|
| 45 |
| [EinsteinArena](https://einsteinarena.com) | optimize | research | 26 | 28 |
|
| 46 |
| [FunSearch](https://github.com/google-deepmind/funsearch) | optimize | research | 3 | 15 |
|
| 47 |
| [Finch / Evolution Fine-Tuning](https://github.com/Open-Galapagos/evolution-fine-tuning) (`erdos_*` tasks) | optimize | research / competition | 12 | 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
-
Construct generators have 4–6 difficulty levels × 10 seeds. Optimize tasks are single research problems, some at several sizes *n*. `families.csv` lists every family with its source, license, domain, `problem_key` and tags.
|
| 50 |
|
| 51 |
## Row schema
|
| 52 |
|
|
@@ -92,6 +99,11 @@ The **optimize reward** is `0` for an invalid answer, else `0.1 + 0.9 · clip(pr
|
|
| 92 |
| `ea_under_review` | EinsteinArena marks the problem as under review. We audited each one and included it only when we could make the check sound |
|
| 93 |
| `unique_answer` | the answer is unique, but it is still verified as a witness (e.g. by expanding a factorization) |
|
| 94 |
| `float_objective`, `exact_integer`, `exact_rational`, ... | how the objective is computed |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
|
| 96 |
## Reference pass rates (pilot, 66 tasks)
|
| 97 |
|
|
@@ -135,9 +147,37 @@ Re-implementing the checkers surfaced problems in the source verifiers that an R
|
|
| 135 |
- AlphaEvolve problem 6: the notebook's functional differs from the one a construction-checker can certify.
|
| 136 |
- Problems with no checkable objective (proof-only or meta problems), or no recoverable construction or verifier.
|
| 137 |
- FunSearch corner-free sets (checker not released).
|
| 138 |
-
- Sources without a license.
|
| 139 |
- Duplicate problem and size pairs across sources (deduplicated by `problem_key`).
|
| 140 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
## License
|
| 142 |
|
| 143 |
-
Each row carries the license of its source (`license` column): MIT (
|
|
|
|
| 1 |
---
|
| 2 |
license: other
|
| 3 |
+
license_name: mixed
|
| 4 |
license_link: LICENSE.md
|
| 5 |
configs:
|
| 6 |
- config_name: construct
|
|
|
|
| 19 |
|
| 20 |
# MathConstructOptimize-Envs
|
| 21 |
|
| 22 |
+
**3,793 RL tasks in 219 families where the model must *construct a mathematical object*, graded by a deterministic checker.** There is no answer matching and no LLM judge in the reward path.
|
| 23 |
|
| 24 |
Most math RL data asks for a final number. Here the model has to produce the object itself: a colouring, a design, a counterexample, a point configuration, a polynomial. The checker accepts **any** valid object, not a stored answer. The collection has two subsets:
|
| 25 |
|
| 26 |
| subset | what the model does | reward | families | tasks |
|
| 27 |
|---|---|---|---|---|
|
| 28 |
| `construct` | produce any object satisfying stated conditions (a witness) | 1 if valid, else 0 | 80 | 3,464 |
|
| 29 |
+
| `optimize` | produce a valid object with the best objective it can (extremal constructions, bound improvement) | 0 if invalid; otherwise 0.1 + 0.9 × progress from a trivial baseline to the best known value | 139 | 329 |
|
| 30 |
|
| 31 |
The runnable sandboxed version (one [Harbor](https://github.com/laude-institute/harbor) task directory per row) is in
|
| 32 |
[`amphora/MathConstructOptimize-Envs-harbor`](https://huggingface.co/datasets/amphora/MathConstructOptimize-Envs-harbor).
|
|
|
|
| 41 |
| [MathConstraint](https://github.com/vireshpati/Math-Constraint) | construct | competition | 33 | 875 |
|
| 42 |
| [NPPC](https://github.com/SMU-DIGA/nppc) | construct | competition | 8 | 480 |
|
| 43 |
| [Reasoning Gym](https://github.com/open-thought/reasoning-gym) | construct | competition | 3 | 180 |
|
| 44 |
+
| [AlphaEvolve repository of problems](https://github.com/google-deepmind/alphaevolve_repository_of_problems) | construct + optimize | research (mostly) | 34 | 203 |
|
| 45 |
| [EinsteinArena](https://einsteinarena.com) | optimize | research | 26 | 28 |
|
| 46 |
| [FunSearch](https://github.com/google-deepmind/funsearch) | optimize | research | 3 | 15 |
|
| 47 |
| [Finch / Evolution Fine-Tuning](https://github.com/Open-Galapagos/evolution-fine-tuning) (`erdos_*` tasks) | optimize | research / competition | 12 | 12 |
|
| 48 |
+
| [Optimization Constants in Mathematics](https://github.com/teorth/optimizationproblems) (Tao, Davis, Ivanisvili) | optimize | research | 13 | 17 |
|
| 49 |
+
| [Leaps in Bounds](https://leapsinbounds.org) (D. Munro) | optimize | research | 14 | 82 |
|
| 50 |
+
| [FrontierShift open problems](https://aitonomy.org/projects/open-problems) (AItonomy Foundation) | optimize | research | 8 | 9 |
|
| 51 |
+
| [FrontierCO](https://huggingface.co/datasets/CO-Bench/FrontierCO) (minimum dominating set only) | optimize | competition | 1 | 15 |
|
| 52 |
+
| [ALE-Bench](https://huggingface.co/datasets/SakanaAI/ALE-Bench) (AtCoder Heuristic Contest) | optimize | competition | 18 | 36 |
|
| 53 |
+
| [FrontierCS](https://github.com/FrontierCS/Frontier-CS) (algorithmic track) | optimize | competition | 14 | 37 |
|
| 54 |
+
| [EdgeBench](https://github.com/ByteDance-Seed/EdgeBench) (released task dirs) | optimize | competition | 2 | 4 |
|
| 55 |
|
| 56 |
+
Construct generators have 4–6 difficulty levels × 10 seeds. Optimize tasks are single research problems or contest instances, some at several sizes *n*. Sources added in v2 (2026-11-18) are described in the v2 section below. `families.csv` lists every family with its source, license, domain, `problem_key` and tags.
|
| 57 |
|
| 58 |
## Row schema
|
| 59 |
|
|
|
|
| 99 |
| `ea_under_review` | EinsteinArena marks the problem as under review. We audited each one and included it only when we could make the check sound |
|
| 100 |
| `unique_answer` | the answer is unique, but it is still verified as a witness (e.g. by expanding a factorization) |
|
| 101 |
| `float_objective`, `exact_integer`, `exact_rational`, ... | how the objective is computed |
|
| 102 |
+
| `reference_is_baseline` / `reference_below_record` | the shipped `reference_answer` is the weak baseline (reward 0.1) or a valid construction weaker than `best_known` |
|
| 103 |
+
| `known_optimum` | `best_known` is a proved optimum, so the reward cannot exceed 1 by improving it |
|
| 104 |
+
| `record_memorizable` | the record object is famous; an agent that recalls it saturates the reward |
|
| 105 |
+
| `license_restricted` | source license restricts derivatives (ALE-Bench, CC BY-ND 4.0) |
|
| 106 |
+
| `license_unknown` | the source states no license (FrontierShift) |
|
| 107 |
|
| 108 |
## Reference pass rates (pilot, 66 tasks)
|
| 109 |
|
|
|
|
| 147 |
- AlphaEvolve problem 6: the notebook's functional differs from the one a construction-checker can certify.
|
| 148 |
- Problems with no checkable objective (proof-only or meta problems), or no recoverable construction or verifier.
|
| 149 |
- FunSearch corner-free sets (checker not released).
|
| 150 |
+
- Sources without a license (v1). v2 includes FrontierShift, which states no license, tagged `license_unknown`.
|
| 151 |
- Duplicate problem and size pairs across sources (deduplicated by `problem_key`).
|
| 152 |
|
| 153 |
+
## v2 (2026-11-18): optimize extension
|
| 154 |
+
|
| 155 |
+
216 new optimize tasks in 77 families (the `construct` subset is unchanged; the previous version is git tag `pre-v2`). Same reward contract and graders interface; every reference answer was re-graded in an isolated copy of the task's `tests/` dir, through `grade.py`, and by the Harbor oracle agent in the sandbox image; a no-op answer scores 0 everywhere. All checks run in under 10 s.
|
| 156 |
+
|
| 157 |
+
| source | families | tasks | license | notes |
|
| 158 |
+
|---|---|---|---|---|
|
| 159 |
+
| Optimization Constants in Mathematics | 13 | 17 | Apache-2.0 | one family per constant where a finite object certifies a bound (Lehmer/Mahler measure, degree vs sensitivity, Komlós discrepancy, matrix-multiplication exponent from exact small-format algorithms, biplanar chromatic number, Bohnenblust–Hille, Berry–Esseen, Brezis–Gallouet–Wainger, sunflower-free families, Fourier entropy–influence, hollow lattice width, narrowest admissible tuples, covering systems) |
|
| 160 |
+
| AlphaEvolve repository (new problems/sizes) | 7 | 16 | CC-BY-4.0 | 2D Nikodym over F_{p²}, Hausdorff–Young, Thomson n=292/306, hexagons in a hexagon, Erdős discrepancy C=3, Szemerédi–Trotter incidences, Rudin L4/L2 spherical harmonics |
|
| 161 |
+
| Leaps in Bounds | 14 | 82 | MIT | cages, degree–diameter, superpermutations, snake/coil-in-the-box, Golomb rulers, no-three-in-line, sorting-network size/depth, equal circles in a square/triangle, isosceles sets, unit squares in a square, disk covering |
|
| 162 |
+
| FrontierShift | 8 | 9 | **unknown** | matrix-multiplication rank 3×3/4×4 over Q, max-determinant ±1 23×23, Boolean nonlinearity n=9, low-weight codeword (decoding challenge n=1280), abc quality, Cramér–Shanks–Granville gap ratio, rational Diophantine septuples, tetrahedra packing density |
|
| 163 |
+
| FrontierCO | 1 | 15 | MIT | minimum dominating set only (the other 7 types overlap CO-Bench) |
|
| 164 |
+
| ALE-Bench | 18 | 36 | **CC BY-ND 4.0** | non-interactive AtCoder Heuristic Contest problems, 2 public-seed instances each; statements kept verbatim; scorers re-implemented in Python and matched against the official tools on ~7,700 outputs |
|
| 165 |
+
| FrontierCS | 14 | 37 | MIT | algorithmic-track problems with deterministic scorers (Max-Cut, Max-3-SAT, Zarankiewicz grids, XOR-Sidon sets, ...); each port matched the upstream checker on ≥100 outputs |
|
| 166 |
+
| EdgeBench | 2 | 4 | CC-BY-4.0 | the two released task directories that run offline (AHC056, AHC058) |
|
| 167 |
+
|
| 168 |
+
**License caveats.** ALE-Bench is CC BY-ND 4.0 (no derivatives): its statements are reproduced verbatim and its tasks carry `license_restricted`; check that your use is compatible before redistributing modified versions. FrontierShift states no license (its repository is not public); those tasks carry `license_unknown`. AtCoder problem statements (ALE-Bench, EdgeBench) remain © AtCoder.
|
| 169 |
+
|
| 170 |
+
**`best_known` provenance.** Values are the published records where available (cited in `tests/instance.json` → `best_known_source`, hidden from the agent). For contest instances and several FrontierCS/ALE problems no per-instance record is published, so `best_known` is our own best solution (tag `best_known_uncertain`); agents can beat it and the reward clips at 1.
|
| 171 |
+
|
| 172 |
+
**Excluded in v2.** Anything overlapping the problem families of HorizonMath, HeuriGym or CO-Bench is left out at every size (e.g. Ramsey/Schur/van der Waerden colourings, kissing numbers, Tammes, spherical designs, difference bases, merit factor, codes and covering designs, Hadamard matrices, sphere packing, TSP/routing, scheduling, bin/rectangle/circle-unequal packing, facility location, set cover, graph colouring, MIS). Also skipped: constants whose certificate is a proof rather than an object, interactive or program-output problems, problems needing a GPU/network/hardware, and problems whose verifier could not be made sound and fast.
|
| 173 |
+
|
| 174 |
+
**Upstream verifier bugs found in v2 sources** (all fixed in our checkers):
|
| 175 |
+
- AlphaEvolve p6 scores a different functional than stated; p13 never checks f̂ ≥ 0; p14 truncates the Fourier integral; p33 clamps coincident points to distance 1e-12; the hexagon-packing outer side is taken as input, not computed; p40 scores the longest valid prefix plus a bonus; p55's sample layout overlaps; p56 silently drops duplicate lines; p57 drops coefficients below 1e-8.
|
| 176 |
+
- EdgeBench AHC058: the eval script reads any `Score = …` line, so a submission can forge the score.
|
| 177 |
+
- FrontierCS 58/8 compare counts only modulo primes; 192/176 ignore trailing tokens; 227 has no range check; 111 and 27 accept empty answers; 193 is a re-encoding of 192.
|
| 178 |
+
- FrontierCO MDS accepts `3.0`/`True` as node ids.
|
| 179 |
+
- ALE-Bench tools: ahc014 turn count wrong, ahc004 panics on Unicode whitespace, ahc024/041 accept an empty output at turn 0.
|
| 180 |
+
|
| 181 |
## License
|
| 182 |
|
| 183 |
+
Each row carries the license of its source (`license` column): MIT (93 families), CC-BY-4.0 (68), Apache-2.0 (32), CC-BY-ND-4.0 (18, ALE-Bench), unknown (8, FrontierShift). Attribution belongs to the original authors of each source listed above. Our packaging, checkers and generators are released under the same terms as the corresponding source.
|
data/optimize.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8056bade5c94873af4cbda5787fbc025d9e42638d36f8367e512c78f6ef6f689
|
| 3 |
+
size 11690357
|
families.csv
CHANGED
|
@@ -1,143 +1,220 @@
|
|
| 1 |
-
family,subset,tier,domain,source,license,problem_key,n_tasks,tags
|
| 2 |
-
ae_p10_kakeya_3d,optimize,research,geometry,AlphaEvolve-Repository-of-Problems/10-3d-kakeya,CC-BY-4.0,kakeya_needle_3d_prisms,1,exact_piecewise_integration;float_objective
|
| 3 |
-
ae_p16_gagliardo_nirenberg,optimize,research,analysis,AlphaEvolve-Repository-of-Problems/16-gagliardo-nirenberg-special-case,CC-BY-4.0,nagy_gagliardo_nirenberg_sharp_constant,3,float_objective;known_optimum
|
| 4 |
-
ae_p17_young_convolution,optimize,research,analysis,AlphaEvolve-Repository-of-Problems/17-young-convolution,CC-BY-4.0,young_convolution_sharp_constant,3,float_objective;known_optimum
|
| 5 |
-
ae_p18_hardy_littlewood_maximal,optimize,research,analysis,AlphaEvolve-Repository-of-Problems/18-hardy-littlewood-maximal,CC-BY-4.0,centered_hardy_littlewood_weak11_constant_1d,1,exact_rational;known_optimum
|
| 6 |
-
ae_p1_ff_kakeya,optimize,research,combinatorics,AlphaEvolve-Repository-of-Problems/1-finite-field-kakeya,CC-BY-4.0,finite_field_kakeya_min_size,10,exact_integer;finite_fields
|
| 7 |
-
ae_p1_ff_nikodym,optimize,research,combinatorics,AlphaEvolve-Repository-of-Problems/1-finite-field-nikodym,CC-BY-4.0,finite_field_nikodym_min_size_d3,4,exact_integer;finite_fields
|
| 8 |
-
ae_p24_de_bruijn_sharma,optimize,research,analysis,AlphaEvolve-Repository-of-Problems/24-de-bruijn-sharma,CC-BY-4.0,de_bruijn_sharma_x_intercept,4,float_objective;polynomials
|
| 9 |
-
ae_p29_block_stacking,optimize,competition,analysis,AlphaEvolve-Repository-of-Problems/29-block-stacking,CC-BY-4.0,block_stacking_overhang_one_per_level,3,agentic_trivial;exact_rational;known_optimum
|
| 10 |
-
ae_p30_arithmetic_kakeya,optimize,research,combinatorics,AlphaEvolve-Repository-of-Problems/30-arithmetic-kakeya,CC-BY-4.0,arithmetic_kakeya_entropy_sum_difference,2,additive_combinatorics;entropy;float_objective
|
| 11 |
-
ae_p31_furstenberg_sarkozy,optimize,research,number_theory,AlphaEvolve-Repository-of-Problems/31-furstenberg-sarkozy,CC-BY-4.0,furstenberg_sarkozy_modular_exponent,2,additive_combinatorics;exact_integer
|
| 12 |
-
ae_p32_spherical_designs,construct,research,discrete_geometry,AlphaEvolve-Repository-of-Problems/32-spherical-designs,CC-BY-4.0,spherical_t_design_s2,6,float_tolerance;numerical_design
|
| 13 |
-
ae_p35_cubes_in_cube,optimize,research,discrete_geometry,AlphaEvolve-Repository-of-Problems/35-packing-in-a-dilate,CC-BY-4.0,unit_cubes_in_smallest_cube_n11,1,float_objective;packing
|
| 14 |
-
ae_p37_turan_tetrahedron,optimize,research,combinatorics,AlphaEvolve-Repository-of-Problems/37-hypergraph-turan-tetrahedron,CC-BY-4.0,turan_density_K4_3,1,blow_up;extremal_hypergraph
|
| 15 |
-
ae_p38_factorial_factors,construct,research,number_theory,AlphaEvolve-Repository-of-Problems/38-factoring-N-factorial,CC-BY-4.0,factorial_into_n_large_factors_A034258,60,agentic_trivial;exact_integer;ilp_friendly;np_search
|
| 16 |
-
ae_p39_beat_the_average,optimize,research,probability,AlphaEvolve-Repository-of-Problems/39-beat-the-average,CC-BY-4.0,beat_the_average_X1X2X3_lt_2X4,1,discrete_measure;float_objective
|
| 17 |
-
ae_p40_erdos_discrepancy,optimize,research,combinatorics,AlphaEvolve-Repository-of-Problems/40-erdos-discrepancy,CC-BY-4.0,erdos_discrepancy_C2_max_length,1,exact_integer;np_search;sat_friendly
|
| 18 |
-
ae_p41_sphere_max_volume,optimize,research,discrete_geometry,AlphaEvolve-Repository-of-Problems/41-points-on-sphere-max-volume,CC-BY-4.0,max_volume_inscribed_polyhedron_n_vertices,7,float_objective
|
| 19 |
-
ae_p42_sum_difference_i,optimize,research,combinatorics,AlphaEvolve-Repository-of-Problems/42-sum-difference-I,CC-BY-4.0,sum_difference_sumset_vs_diffset_exponent,1,additive_combinatorics;exact_integer
|
| 20 |
-
ae_p43_sum_difference_ii,optimize,research,combinatorics,AlphaEvolve-Repository-of-Problems/43-sum-difference-II,CC-BY-4.0,sum_difference_diffset_vs_sumset_exponent,1,additive_combinatorics;exact_integer
|
| 21 |
-
ae_p44_sum_difference_iii,optimize,research,combinatorics,AlphaEvolve-Repository-of-Problems/44-sum-difference-III,CC-BY-4.0,sum_difference_A_plus_B_vs_A_minus_B_exponent,1,additive_combinatorics;exact_integer
|
| 22 |
-
ae_p45_sum_product_fp,optimize,research,combinatorics,AlphaEvolve-Repository-of-Problems/45-sum-product-finite-field,Apache-2.0,finite_field_sum_product_sqrt_p,3,additive_combinatorics;exact_integer
|
| 23 |
-
ae_p52_erdos_squarefree,construct,research,number_theory,AlphaEvolve-Repository-of-Problems/52-erdos-squarefree,CC-BY-4.0,erdos_ab_plus_1_never_squarefree,50,exact_integer
|
| 24 |
-
ae_p54_touching_cylinders,construct,research,discrete_geometry,AlphaEvolve-Repository-of-Problems/54-pairwise-touching-cylinders,CC-BY-4.0,mutually_touching_infinite_cylinders,2,float_tolerance;nonlinear_system
|
| 25 |
-
ae_p58_happy_ending,construct,research,discrete_geometry,AlphaEvolve-Repository-of-Problems/58-erdos-szekeres-happy-ending,CC-BY-4.0,erdos_szekeres_no_convex_k_gon_2pow_k_minus_2,5,exact_integer;np_search
|
| 26 |
-
ae_p59_isosceles_free_grid,optimize,research,discrete_geometry,AlphaEvolve-Repository-of-Problems/59-no-isosceles-grid,CC-BY-4.0,isosceles_free_grid_subset,2,exact_integer;np_search
|
| 27 |
-
ae_p60_no5_on_sphere,optimize,research,discrete_geometry,AlphaEvolve-Repository-of-Problems/60-no-5-on-a-sphere,CC-BY-4.0,no_five_cospherical_grid_subset,6,exact_integer;np_search
|
| 28 |
-
ae_p65_imo2025_p6_tiling,construct,competition,combinatorics,AlphaEvolve-Repository-of-Problems/65-imo-2025-p6,CC-BY-4.0,imo2025_p6_min_tiles,6,exact_integer
|
| 29 |
-
ea_circle_packing_26,optimize,research,discrete_geometry,EinsteinArena/circle-packing,MIT,circle_packing_square_sum_radii_n26,1,exact_check;float_objective
|
| 30 |
-
ea_circles_rectangle_21,optimize,research,discrete_geometry,EinsteinArena/circles-rectangle,MIT,circles_in_rectangle_perimeter4_sum_radii_n21,1,exact_check;float_objective
|
| 31 |
-
ea_difference_bases,optimize,research,number_theory,EinsteinArena/difference-bases,MIT,difference_basis_ratio,1,exact_check
|
| 32 |
-
ea_edges_vs_triangles,optimize,research,combinatorics,EinsteinArena/edges-vs-triangles,MIT,edges_vs_triangles_density_curve,1,float_objective
|
| 33 |
-
ea_erdos_min_overlap,optimize,research,analysis,EinsteinArena/erdos-min-overlap,MIT,erdos_minimum_overlap_upper,1,float_objective
|
| 34 |
-
ea_first_autocorrelation,optimize,research,analysis,EinsteinArena/first-autocorrelation-inequality,MIT,first_autocorrelation_inequality_upper,1,float_objective
|
| 35 |
-
ea_flat_polynomials_70,optimize,research,analysis,EinsteinArena/flat-polynomials,MIT,flat_littlewood_polynomial_n70,1,float_objective
|
| 36 |
-
ea_hadamard_det_51,optimize,research,combinatorics,EinsteinArena/hadamard-det-51,MIT,hadamard_maxdet_n51,1,ea_under_review;exact_check
|
| 37 |
-
ea_heilbronn_triangle_11,optimize,research,discrete_geometry,EinsteinArena/heilbronn-triangles,MIT,heilbronn_triangle_n11,1,exact_check;float_objective
|
| 38 |
-
ea_kakeya_needle_128,optimize,research,geometry,EinsteinArena/kakeya-needle-128,MIT,kakeya_needle_triangles_n128,1,ea_under_review;exact_check
|
| 39 |
-
ea_kissing_number,optimize,research,discrete_geometry,"EinsteinArena/kissing-number-d11,-d11-605,-d12",MIT,kissing_number_overlap_loss,3,best_known_uncertain;exact_check
|
| 40 |
-
ea_min_distance_ratio_16,optimize,research,discrete_geometry,EinsteinArena/min-distance-ratio-2d,MIT,max_min_distance_ratio_2d_n16,1,float_objective
|
| 41 |
-
ea_no_three_in_line_75,optimize,research,discrete_geometry,EinsteinArena/no-three-in-line-75,MIT,no_three_in_line_n75,1,ea_under_review;exact_check
|
| 42 |
-
ea_prime_number_theorem,optimize,research,number_theory,EinsteinArena/prime-number-theorem,MIT,pnt_chebyshev_certificate,1,float_objective;range_limited_certificate
|
| 43 |
-
ea_ring_loading_15,optimize,research,combinatorics,EinsteinArena/ring-loading-15,MIT,ring_loading_m15,1,ea_under_review;exact_check
|
| 44 |
-
ea_second_autocorrelation,optimize,research,analysis,EinsteinArena/second-autocorrelation-inequality,MIT,second_autocorrelation_inequality_lower,1,float_objective
|
| 45 |
-
ea_shannon_c7_5,optimize,research,graph_theory,EinsteinArena/shannon-capacity-c7-5,MIT,independent_set_c7_strong_power5,1,ea_under_review;exact_check
|
| 46 |
-
ea_sidon_45_set,optimize,research,number_theory,EinsteinArena/sidon-45-set,MIT,sidon_subsets_of_45_sets,1,ea_under_review;exact_check
|
| 47 |
-
ea_snake_in_the_box_13,optimize,research,graph_theory,EinsteinArena/snake-in-the-box-13,MIT,snake_in_the_box_d13,1,ea_under_review;exact_check
|
| 48 |
-
ea_sorting_network_16,optimize,research,combinatorics,EinsteinArena/sorting-network-16,MIT,sorting_network_size_n16,1,ea_under_review;exact_check
|
| 49 |
-
ea_spencer_discrepancy,optimize,research,combinatorics,EinsteinArena/spencer-discrepancy,MIT,spencer_discrepancy_square_n_le20,1,ea_under_review;exact_check
|
| 50 |
-
ea_tammes,optimize,research,discrete_geometry,EinsteinArena/tammes-problem,MIT,tammes_n50,1,float_objective
|
| 51 |
-
ea_third_autocorrelation,optimize,research,analysis,EinsteinArena/third-autocorrelation-inequality,MIT,third_autocorrelation_inequality_upper,1,float_objective
|
| 52 |
-
ea_thomson_282,optimize,research,discrete_geometry,EinsteinArena/thomson-problem,MIT,thomson_problem_n282,1,float_objective
|
| 53 |
-
ea_two_deletion_code_16,optimize,research,coding_theory,EinsteinArena/two-deletion-code-16,MIT,two_deletion_code_n16,1,ea_under_review;exact_check
|
| 54 |
-
ea_uncertainty_principle,optimize,research,analysis,EinsteinArena/uncertainty-principle,MIT,plus1_uncertainty_principle_upper,1,high_precision
|
| 55 |
-
finch_3ap_diffs_40,optimize,research,combinatorics,Finch-EFT/skydiscover/erdos_1097_3ap_diffs_n40,Apache-2.0,erdos1097_3ap_differences_n40_m400,1,best_known_uncertain;exact_check;np_search
|
| 56 |
-
finch_4subset_3dist_16,optimize,research,discrete_geometry,Finch-EFT/skydiscover/erdos_659_4subset_3dist_construction,Apache-2.0,erdos659_4sets_3dist_n16,1,best_known_uncertain;exact_check;np_search
|
| 57 |
-
finch_flat_poly_32,optimize,research,analysis,Finch-EFT/skydiscover/erdos_flat_polynomials_n32,Apache-2.0,flat_littlewood_polynomial_n32,1,best_known_uncertain;float_objective;np_search
|
| 58 |
-
finch_heilbronn_disk_12,optimize,research,discrete_geometry,Finch-EFT/skydiscover/erdos_507_heilbronn_disk_n12,Apache-2.0,heilbronn_disk_n12,1,best_known_uncertain;exact_check;float_objective
|
| 59 |
-
finch_isosceles_free_grid_8,optimize,competition,discrete_geometry,Finch-EFT/skydiscover/erdos_isosceles_free_grid,Apache-2.0,isosceles_free_grid_subset,1,exact_check;exact_optimum_known;np_search
|
| 60 |
-
finch_lcm_chain_10000,optimize,competition,number_theory,Finch-EFT/skydiscover/erdos_440_lcm_density,Apache-2.0,erdos440_lcm_consecutive_x10000,1,exact_check;exact_optimum_known
|
| 61 |
-
finch_newman_200,optimize,research,number_theory,Finch-EFT/skydiscover/erdos_480_newman_density,Apache-2.0,erdos480_newman_finite_n200,1,best_known_uncertain;float_objective
|
| 62 |
-
finch_no4_concyclic_12,optimize,research,discrete_geometry,Finch-EFT/skydiscover/erdos_654_no_four_concyclic_distances,Apache-2.0,erdos654_no4_concyclic_n12,1,best_known_uncertain;exact_check;np_search
|
| 63 |
-
finch_sidon_pair_100,optimize,research,number_theory,Finch-EFT/skydiscover/erdos_43_sidon_pair,Apache-2.0,erdos43_sidon_pair_n100,1,best_known_uncertain;exact_check;np_search
|
| 64 |
-
finch_sidon_set_121,optimize,competition,number_theory,Finch-EFT/skydiscover/erdos_difference_bases_N121,Apache-2.0,max_sidon_set_0_120,1,exact_check;exact_optimum_known
|
| 65 |
-
finch_square_packing_12,optimize,research,discrete_geometry,Finch-EFT/skydiscover/erdos_106_square_packing,Apache-2.0,erdos106_squares_in_square_n12,1,exact_check
|
| 66 |
-
finch_udg_girth_30,optimize,research,graph_theory,Finch-EFT/skydiscover/erdos_705_unit_distance_high_girth,Apache-2.0,erdos705_udg_chi4_girth_n30,1,best_known_uncertain;exact_check
|
| 67 |
-
fs_admissible_set,optimize,research,combinatorics,FunSearch/admissible_set,Apache-2.0,admissible_set_constant_weight,2,integer_objective
|
| 68 |
-
fs_cap_set,optimize,research,combinatorics,FunSearch/cap_set,Apache-2.0,cap_set_f3n,6,integer_objective
|
| 69 |
-
fs_cycle_independent_set,optimize,research,graph_theory,FunSearch/cyclic_graphs,Apache-2.0,independent_set_strong_power_odd_cycle,7,integer_objective
|
| 70 |
-
mc_all_interval,construct,competition,combinatorics,MathConstraint/all_interval,CC-BY-4.0,all_interval_series,40,agentic_trivial
|
| 71 |
-
mc_antimagic_square,construct,competition,combinatorics,MathConstraint/antimagic_square,CC-BY-4.0,antimagic_square,6,np_search
|
| 72 |
-
mc_bibd,construct,competition,combinatorics,MathConstraint/bibd,CC-BY-4.0,bibd,28,np_search
|
| 73 |
-
mc_costas_array,construct,competition,combinatorics,MathConstraint/costas_array,CC-BY-4.0,costas_array,23,np_search
|
| 74 |
-
mc_debruijn,construct,competition,combinatorics,MathConstraint/debruijn,CC-BY-4.0,de_bruijn_sequence,22,agentic_trivial
|
| 75 |
-
mc_golomb,construct,competition,combinatorics,MathConstraint/golomb,CC-BY-4.0,golomb_ruler,18,np_search
|
| 76 |
-
mc_graceful_graph,construct,competition,graph_theory,MathConstraint/graceful_graph,CC-BY-4.0,graceful_labeling,17,np_search
|
| 77 |
-
mc_graph_k_coloring,construct,competition,graph_theory,MathConstraint/graph_k_coloring,CC-BY-4.0,graph_k_coloring,48,np_search
|
| 78 |
-
mc_hadamard,construct,competition,combinatorics,MathConstraint/hadamard,CC-BY-4.0,legendre_pair,30,np_search
|
| 79 |
-
mc_langford,construct,competition,combinatorics,MathConstraint/langford,CC-BY-4.0,langford_pairing,27,agentic_trivial;np_search
|
| 80 |
-
mc_low_autocorrelation,construct,competition,combinatorics,MathConstraint/low_autocorrelation,CC-BY-4.0,low_autocorrelation_binary_sequence,31,np_search
|
| 81 |
-
mc_magic_sequence,construct,competition,combinatorics,MathConstraint/magic_sequence,CC-BY-4.0,magic_sequence,30,agentic_trivial
|
| 82 |
-
mc_max_clique,construct,competition,graph_theory,MathConstraint/max_clique,CC-BY-4.0,graph_clique,55,np_search
|
| 83 |
-
mc_max_independent_set,construct,competition,graph_theory,MathConstraint/max_independent_set,CC-BY-4.0,graph_independent_set,60,np_search
|
| 84 |
-
mc_non_transitive_dice,construct,competition,probability,MathConstraint/non_transitive_dice,CC-BY-4.0,intransitive_dice,15,agentic_trivial;np_search
|
| 85 |
-
mc_number_partitioning,construct,competition,number_theory,MathConstraint/number_partitioning,CC-BY-4.0,equal_sum_partition_1_to_n,59,agentic_trivial
|
| 86 |
-
mc_ortholatin,construct,competition,combinatorics,MathConstraint/ortholatin,CC-BY-4.0,orthogonal_latin_squares,21,np_search
|
| 87 |
-
mc_pysms_chromatic_girth,construct,competition,graph_theory,MathConstraint/pysms_chromatic_girth,CC-BY-4.0,graph_existence_chromatic_girth,25,np_search
|
| 88 |
-
mc_pysms_clique_coloring,construct,competition,graph_theory,MathConstraint/pysms_clique_coloring,CC-BY-4.0,graph_existence_clique_coloring,16,np_search
|
| 89 |
-
mc_pysms_degree_bounds,construct,competition,graph_theory,MathConstraint/pysms_degree_bounds,CC-BY-4.0,graph_existence_degree_bounds,11,agentic_trivial;np_search
|
| 90 |
-
mc_pysms_girth_degree,construct,competition,graph_theory,MathConstraint/pysms_girth_degree,CC-BY-4.0,graph_existence_girth_degree,18,np_search
|
| 91 |
-
mc_pysms_graph_builder,construct,competition,graph_theory,MathConstraint/pysms_graph_builder,CC-BY-4.0,graph_existence_graph_builder,8,np_search
|
| 92 |
-
mc_pysms_independent_connectivity,construct,competition,graph_theory,MathConstraint/pysms_independent_connectivity,CC-BY-4.0,graph_existence_independent_connectivity,15,np_search
|
| 93 |
-
mc_pysms_min_connectivity,construct,competition,graph_theory,MathConstraint/pysms_min_connectivity,CC-BY-4.0,graph_existence_min_connectivity,12,agentic_trivial;np_search
|
| 94 |
-
mc_pysms_min_degree,construct,competition,graph_theory,MathConstraint/pysms_min_degree,CC-BY-4.0,graph_existence_min_degree,12,agentic_trivial;np_search
|
| 95 |
-
mc_pysms_min_girth,construct,competition,graph_theory,MathConstraint/pysms_min_girth,CC-BY-4.0,graph_existence_min_girth,13,agentic_trivial;np_search
|
| 96 |
-
mc_pysms_mtf,construct,competition,graph_theory,MathConstraint/pysms_mtf,CC-BY-4.0,maximal_triangle_free_graph,12,agentic_trivial;np_search
|
| 97 |
-
mc_pysms_num_edges_bounds,construct,competition,graph_theory,MathConstraint/pysms_num_edges_bounds,CC-BY-4.0,graph_existence_num_edges_bounds,12,agentic_trivial;np_search
|
| 98 |
-
mc_quasigroup_idempotent,construct,competition,algebra,MathConstraint/quasigroup_idempotent,CC-BY-4.0,idempotent_qg3_quasigroup,12,np_search
|
| 99 |
-
mc_ramsey,construct,competition,combinatorics,MathConstraint/ramsey,CC-BY-4.0,ramsey_two_colouring,54,np_search
|
| 100 |
-
mc_social_golfers,construct,competition,combinatorics,MathConstraint/social_golfers,CC-BY-4.0,social_golfer,23,np_search
|
| 101 |
-
mc_van_der_waerden,construct,competition,combinatorics,MathConstraint/van_der_waerden,CC-BY-4.0,van_der_waerden_colouring,42,np_search
|
| 102 |
-
mc_vertex_cover,construct,competition,graph_theory,MathConstraint/vertex_cover,CC-BY-4.0,graph_vertex_cover,60,np_search
|
| 103 |
-
nppc_bandwidth,construct,competition,graph_theory,NPPC/bandwidth,MIT,graph_bandwidth,60,agentic_trivial;np_search
|
| 104 |
-
nppc_clique,construct,competition,graph_theory,NPPC/clique,MIT,graph_clique,60,agentic_trivial;np_search
|
| 105 |
-
nppc_dominating_set,construct,competition,graph_theory,NPPC/dominating_set,MIT,graph_dominating_set,60,agentic_trivial;np_search
|
| 106 |
-
nppc_independent_set,construct,competition,graph_theory,NPPC/independent_set,MIT,graph_independent_set,60,agentic_trivial;np_search
|
| 107 |
-
nppc_quad_diophantine,construct,competition,number_theory,NPPC/quad_diop_equ,MIT,quadratic_diophantine_ax2_by_c,60,agentic_trivial;np_search
|
| 108 |
-
nppc_quadratic_congruence,construct,competition,number_theory,NPPC/quadratic_congruence,MIT,quadratic_congruence_bounded,60,agentic_trivial;np_search
|
| 109 |
-
nppc_three_coloring,construct,competition,graph_theory,NPPC/graph_three_colorability,MIT,graph_3_coloring,60,agentic_trivial;np_search
|
| 110 |
-
nppc_vertex_cover,construct,competition,graph_theory,NPPC/vertex_cover,MIT,graph_vertex_cover,60,agentic_trivial;np_search
|
| 111 |
-
rg_graph_color,construct,competition,graph_theory,ReasoningGym/graph_color,Apache-2.0,graph_k_coloring,60,agentic_trivial;np_search
|
| 112 |
-
rg_intermediate_integration,construct,competition,analysis,ReasoningGym/intermediate_integration,Apache-2.0,symbolic_antiderivative,60,symbolic
|
| 113 |
-
rg_simple_integration,construct,competition,analysis,ReasoningGym/simple_integration,Apache-2.0,symbolic_antiderivative_polynomial,60,symbolic
|
| 114 |
-
rlve_antiderivative,construct,competition,analysis,RLVE-Gym/integral,MIT,symbolic_antiderivative,60,
|
| 115 |
-
rlve_bezout_identity,construct,competition,number_theory,RLVE-Gym/bezout_identity,MIT,bezout_coefficients,60,agentic_trivial
|
| 116 |
-
rlve_construct_hack_interval,construct,competition,number_theory,RLVE-Gym/construct_hack_interval,MIT,cf468c_hack_interval,60,
|
| 117 |
-
rlve_crt,construct,competition,number_theory,RLVE-Gym/crt,MIT,generalized_crt,60,agentic_trivial
|
| 118 |
-
rlve_distinct_subset_sum_permutation,construct,competition,combinatorics,RLVE-Gym/distinct_array_permutation,MIT,cf892d_gluttony,60,agentic_trivial
|
| 119 |
-
rlve_even_degree_partition,construct,competition,graph_theory,RLVE-Gym/even_degree_graph_partitioning,MIT,gallai_even_partition,60,agentic_trivial
|
| 120 |
-
rlve_graph_isomorphism,construct,competition,graph_theory,RLVE-Gym/graph_isomorphism,MIT,graph_isomorphism,60,agentic_trivial;np_search
|
| 121 |
-
rlve_grid_parity_construction,construct,competition,algebra,RLVE-Gym/grid_parity_construction,MIT,lights_out_gf2,60,agentic_trivial
|
| 122 |
-
rlve_imp_party,construct,competition,graph_theory,RLVE-Gym/imp_party,MIT,poi_party_clique_3n,60,agentic_trivial
|
| 123 |
-
rlve_integer_linear_system,construct,competition,algebra,RLVE-Gym/gaussian_elimination,MIT,integer_linear_system,60,agentic_trivial
|
| 124 |
-
rlve_largest_convex_polygon,construct,competition,discrete_geometry,RLVE-Gym/largest_convex_polygon,MIT,largest_convex_subset,60,agentic_trivial
|
| 125 |
-
rlve_largest_rectangle,construct,competition,discrete_geometry,RLVE-Gym/largest_rectangle_among_points,MIT,largest_rectangle_in_point_set,60,agentic_trivial
|
| 126 |
-
rlve_matrix_permutation_equivalence,construct,competition,combinatorics,RLVE-Gym/matrix_permutation_equivalence,MIT,binary_matrix_permutation_equivalence,60,agentic_trivial;np_search
|
| 127 |
-
rlve_max_achromatic_coloring,construct,competition,graph_theory,RLVE-Gym/maximum_achromatic_number,MIT,achromatic_number,60,agentic_trivial;np_search
|
| 128 |
-
rlve_maximum_clique,construct,competition,graph_theory,RLVE-Gym/maximum_clique,MIT,maximum_clique,60,agentic_trivial;np_search
|
| 129 |
-
rlve_min_chromatic_number,construct,competition,graph_theory,RLVE-Gym/minimum_chromatic_number,MIT,graph_k_coloring_chromatic,60,agentic_trivial;np_search
|
| 130 |
-
rlve_min_harmonious_coloring,construct,competition,graph_theory,RLVE-Gym/minimum_harmonious_chromatic_number,MIT,harmonious_chromatic_number,60,agentic_trivial;np_search
|
| 131 |
-
rlve_pairwise_sums_recovery,construct,competition,combinatorics,RLVE-Gym/squ_squarks,MIT,poi_squarks_pairwise_sums,60,agentic_trivial
|
| 132 |
-
rlve_pan_solar_panels,construct,competition,number_theory,RLVE-Gym/pan_solar_panels,MIT,poi_solar_panels_max_gcd,60,agentic_trivial
|
| 133 |
-
rlve_polynomial_global_minimum,construct,competition,analysis,RLVE-Gym/polynomial_minimum,MIT,polynomial_global_minimum,60,agentic_trivial
|
| 134 |
-
rlve_polynomial_integer_roots,construct,competition,algebra,RLVE-Gym/polynomial_factorization,MIT,integer_root_factorization,60,agentic_trivial;unique_answer
|
| 135 |
-
rlve_polynomial_interpolation,construct,competition,algebra,RLVE-Gym/polynomial_interpolation,MIT,lagrange_interpolation_integer,60,agentic_trivial;unique_answer
|
| 136 |
-
rlve_prefix_product_permutation,construct,competition,number_theory,RLVE-Gym/prefix_product_mod_distinct_permutation,MIT,cf487c_prefix_product_sequence,60,
|
| 137 |
-
rlve_prefix_sum_permutation,construct,competition,number_theory,RLVE-Gym/prefix_sum_mod_distinct_permutation,MIT,prefix_sum_mod_distinct_permutation,60,
|
| 138 |
-
rlve_prime_graph_coloring,construct,competition,graph_theory,RLVE-Gym/prime_graph_minimum_chromatic_number,MIT,prime_distance_graph_coloring,60,agentic_trivial
|
| 139 |
-
rlve_recursive_sequence_sum,construct,competition,number_theory,RLVE-Gym/recursive_sequence_sum_construction,MIT,linear_recurrence_subset_sum,60,agentic_trivial
|
| 140 |
-
rlve_round_robin_scores,construct,competition,combinatorics,RLVE-Gym/round_robin,MIT,tournament_score_realisation_3_1_0,60,agentic_trivial
|
| 141 |
-
rlve_shortest_path_count,construct,competition,combinatorics,RLVE-Gym/shortest_path_count_construction,MIT,cf388b_shortest_path_count,60,
|
| 142 |
-
rlve_smallest_enclosing_circle,construct,competition,geometry,RLVE-Gym/smallest_circle,MIT,minimum_enclosing_circle,60,agentic_trivial
|
| 143 |
-
rlve_subgraph_isomorphism,construct,competition,graph_theory,RLVE-Gym/subgraph_isomorphism,MIT,induced_subgraph_isomorphism,60,agentic_trivial;np_search
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
family,subset,tier,domain,source,license,problem_key,n_tasks,tags
|
| 2 |
+
ae_p10_kakeya_3d,optimize,research,geometry,AlphaEvolve-Repository-of-Problems/10-3d-kakeya,CC-BY-4.0,kakeya_needle_3d_prisms,1,exact_piecewise_integration;float_objective
|
| 3 |
+
ae_p16_gagliardo_nirenberg,optimize,research,analysis,AlphaEvolve-Repository-of-Problems/16-gagliardo-nirenberg-special-case,CC-BY-4.0,nagy_gagliardo_nirenberg_sharp_constant,3,float_objective;known_optimum
|
| 4 |
+
ae_p17_young_convolution,optimize,research,analysis,AlphaEvolve-Repository-of-Problems/17-young-convolution,CC-BY-4.0,young_convolution_sharp_constant,3,float_objective;known_optimum
|
| 5 |
+
ae_p18_hardy_littlewood_maximal,optimize,research,analysis,AlphaEvolve-Repository-of-Problems/18-hardy-littlewood-maximal,CC-BY-4.0,centered_hardy_littlewood_weak11_constant_1d,1,exact_rational;known_optimum
|
| 6 |
+
ae_p1_ff_kakeya,optimize,research,combinatorics,AlphaEvolve-Repository-of-Problems/1-finite-field-kakeya,CC-BY-4.0,finite_field_kakeya_min_size,10,exact_integer;finite_fields
|
| 7 |
+
ae_p1_ff_nikodym,optimize,research,combinatorics,AlphaEvolve-Repository-of-Problems/1-finite-field-nikodym,CC-BY-4.0,finite_field_nikodym_min_size_d3,4,exact_integer;finite_fields
|
| 8 |
+
ae_p24_de_bruijn_sharma,optimize,research,analysis,AlphaEvolve-Repository-of-Problems/24-de-bruijn-sharma,CC-BY-4.0,de_bruijn_sharma_x_intercept,4,float_objective;polynomials
|
| 9 |
+
ae_p29_block_stacking,optimize,competition,analysis,AlphaEvolve-Repository-of-Problems/29-block-stacking,CC-BY-4.0,block_stacking_overhang_one_per_level,3,agentic_trivial;exact_rational;known_optimum
|
| 10 |
+
ae_p30_arithmetic_kakeya,optimize,research,combinatorics,AlphaEvolve-Repository-of-Problems/30-arithmetic-kakeya,CC-BY-4.0,arithmetic_kakeya_entropy_sum_difference,2,additive_combinatorics;entropy;float_objective
|
| 11 |
+
ae_p31_furstenberg_sarkozy,optimize,research,number_theory,AlphaEvolve-Repository-of-Problems/31-furstenberg-sarkozy,CC-BY-4.0,furstenberg_sarkozy_modular_exponent,2,additive_combinatorics;exact_integer
|
| 12 |
+
ae_p32_spherical_designs,construct,research,discrete_geometry,AlphaEvolve-Repository-of-Problems/32-spherical-designs,CC-BY-4.0,spherical_t_design_s2,6,float_tolerance;numerical_design
|
| 13 |
+
ae_p35_cubes_in_cube,optimize,research,discrete_geometry,AlphaEvolve-Repository-of-Problems/35-packing-in-a-dilate,CC-BY-4.0,unit_cubes_in_smallest_cube_n11,1,float_objective;packing
|
| 14 |
+
ae_p37_turan_tetrahedron,optimize,research,combinatorics,AlphaEvolve-Repository-of-Problems/37-hypergraph-turan-tetrahedron,CC-BY-4.0,turan_density_K4_3,1,blow_up;extremal_hypergraph
|
| 15 |
+
ae_p38_factorial_factors,construct,research,number_theory,AlphaEvolve-Repository-of-Problems/38-factoring-N-factorial,CC-BY-4.0,factorial_into_n_large_factors_A034258,60,agentic_trivial;exact_integer;ilp_friendly;np_search
|
| 16 |
+
ae_p39_beat_the_average,optimize,research,probability,AlphaEvolve-Repository-of-Problems/39-beat-the-average,CC-BY-4.0,beat_the_average_X1X2X3_lt_2X4,1,discrete_measure;float_objective
|
| 17 |
+
ae_p40_erdos_discrepancy,optimize,research,combinatorics,AlphaEvolve-Repository-of-Problems/40-erdos-discrepancy,CC-BY-4.0,erdos_discrepancy_C2_max_length,1,exact_integer;np_search;sat_friendly
|
| 18 |
+
ae_p41_sphere_max_volume,optimize,research,discrete_geometry,AlphaEvolve-Repository-of-Problems/41-points-on-sphere-max-volume,CC-BY-4.0,max_volume_inscribed_polyhedron_n_vertices,7,float_objective
|
| 19 |
+
ae_p42_sum_difference_i,optimize,research,combinatorics,AlphaEvolve-Repository-of-Problems/42-sum-difference-I,CC-BY-4.0,sum_difference_sumset_vs_diffset_exponent,1,additive_combinatorics;exact_integer
|
| 20 |
+
ae_p43_sum_difference_ii,optimize,research,combinatorics,AlphaEvolve-Repository-of-Problems/43-sum-difference-II,CC-BY-4.0,sum_difference_diffset_vs_sumset_exponent,1,additive_combinatorics;exact_integer
|
| 21 |
+
ae_p44_sum_difference_iii,optimize,research,combinatorics,AlphaEvolve-Repository-of-Problems/44-sum-difference-III,CC-BY-4.0,sum_difference_A_plus_B_vs_A_minus_B_exponent,1,additive_combinatorics;exact_integer
|
| 22 |
+
ae_p45_sum_product_fp,optimize,research,combinatorics,AlphaEvolve-Repository-of-Problems/45-sum-product-finite-field,Apache-2.0,finite_field_sum_product_sqrt_p,3,additive_combinatorics;exact_integer
|
| 23 |
+
ae_p52_erdos_squarefree,construct,research,number_theory,AlphaEvolve-Repository-of-Problems/52-erdos-squarefree,CC-BY-4.0,erdos_ab_plus_1_never_squarefree,50,exact_integer
|
| 24 |
+
ae_p54_touching_cylinders,construct,research,discrete_geometry,AlphaEvolve-Repository-of-Problems/54-pairwise-touching-cylinders,CC-BY-4.0,mutually_touching_infinite_cylinders,2,float_tolerance;nonlinear_system
|
| 25 |
+
ae_p58_happy_ending,construct,research,discrete_geometry,AlphaEvolve-Repository-of-Problems/58-erdos-szekeres-happy-ending,CC-BY-4.0,erdos_szekeres_no_convex_k_gon_2pow_k_minus_2,5,exact_integer;np_search
|
| 26 |
+
ae_p59_isosceles_free_grid,optimize,research,discrete_geometry,AlphaEvolve-Repository-of-Problems/59-no-isosceles-grid,CC-BY-4.0,isosceles_free_grid_subset,2,exact_integer;np_search
|
| 27 |
+
ae_p60_no5_on_sphere,optimize,research,discrete_geometry,AlphaEvolve-Repository-of-Problems/60-no-5-on-a-sphere,CC-BY-4.0,no_five_cospherical_grid_subset,6,exact_integer;np_search
|
| 28 |
+
ae_p65_imo2025_p6_tiling,construct,competition,combinatorics,AlphaEvolve-Repository-of-Problems/65-imo-2025-p6,CC-BY-4.0,imo2025_p6_min_tiles,6,exact_integer
|
| 29 |
+
ea_circle_packing_26,optimize,research,discrete_geometry,EinsteinArena/circle-packing,MIT,circle_packing_square_sum_radii_n26,1,exact_check;float_objective
|
| 30 |
+
ea_circles_rectangle_21,optimize,research,discrete_geometry,EinsteinArena/circles-rectangle,MIT,circles_in_rectangle_perimeter4_sum_radii_n21,1,exact_check;float_objective
|
| 31 |
+
ea_difference_bases,optimize,research,number_theory,EinsteinArena/difference-bases,MIT,difference_basis_ratio,1,exact_check
|
| 32 |
+
ea_edges_vs_triangles,optimize,research,combinatorics,EinsteinArena/edges-vs-triangles,MIT,edges_vs_triangles_density_curve,1,float_objective
|
| 33 |
+
ea_erdos_min_overlap,optimize,research,analysis,EinsteinArena/erdos-min-overlap,MIT,erdos_minimum_overlap_upper,1,float_objective
|
| 34 |
+
ea_first_autocorrelation,optimize,research,analysis,EinsteinArena/first-autocorrelation-inequality,MIT,first_autocorrelation_inequality_upper,1,float_objective
|
| 35 |
+
ea_flat_polynomials_70,optimize,research,analysis,EinsteinArena/flat-polynomials,MIT,flat_littlewood_polynomial_n70,1,float_objective
|
| 36 |
+
ea_hadamard_det_51,optimize,research,combinatorics,EinsteinArena/hadamard-det-51,MIT,hadamard_maxdet_n51,1,ea_under_review;exact_check
|
| 37 |
+
ea_heilbronn_triangle_11,optimize,research,discrete_geometry,EinsteinArena/heilbronn-triangles,MIT,heilbronn_triangle_n11,1,exact_check;float_objective
|
| 38 |
+
ea_kakeya_needle_128,optimize,research,geometry,EinsteinArena/kakeya-needle-128,MIT,kakeya_needle_triangles_n128,1,ea_under_review;exact_check
|
| 39 |
+
ea_kissing_number,optimize,research,discrete_geometry,"EinsteinArena/kissing-number-d11,-d11-605,-d12",MIT,kissing_number_overlap_loss,3,best_known_uncertain;exact_check
|
| 40 |
+
ea_min_distance_ratio_16,optimize,research,discrete_geometry,EinsteinArena/min-distance-ratio-2d,MIT,max_min_distance_ratio_2d_n16,1,float_objective
|
| 41 |
+
ea_no_three_in_line_75,optimize,research,discrete_geometry,EinsteinArena/no-three-in-line-75,MIT,no_three_in_line_n75,1,ea_under_review;exact_check
|
| 42 |
+
ea_prime_number_theorem,optimize,research,number_theory,EinsteinArena/prime-number-theorem,MIT,pnt_chebyshev_certificate,1,float_objective;range_limited_certificate
|
| 43 |
+
ea_ring_loading_15,optimize,research,combinatorics,EinsteinArena/ring-loading-15,MIT,ring_loading_m15,1,ea_under_review;exact_check
|
| 44 |
+
ea_second_autocorrelation,optimize,research,analysis,EinsteinArena/second-autocorrelation-inequality,MIT,second_autocorrelation_inequality_lower,1,float_objective
|
| 45 |
+
ea_shannon_c7_5,optimize,research,graph_theory,EinsteinArena/shannon-capacity-c7-5,MIT,independent_set_c7_strong_power5,1,ea_under_review;exact_check
|
| 46 |
+
ea_sidon_45_set,optimize,research,number_theory,EinsteinArena/sidon-45-set,MIT,sidon_subsets_of_45_sets,1,ea_under_review;exact_check
|
| 47 |
+
ea_snake_in_the_box_13,optimize,research,graph_theory,EinsteinArena/snake-in-the-box-13,MIT,snake_in_the_box_d13,1,ea_under_review;exact_check
|
| 48 |
+
ea_sorting_network_16,optimize,research,combinatorics,EinsteinArena/sorting-network-16,MIT,sorting_network_size_n16,1,ea_under_review;exact_check
|
| 49 |
+
ea_spencer_discrepancy,optimize,research,combinatorics,EinsteinArena/spencer-discrepancy,MIT,spencer_discrepancy_square_n_le20,1,ea_under_review;exact_check
|
| 50 |
+
ea_tammes,optimize,research,discrete_geometry,EinsteinArena/tammes-problem,MIT,tammes_n50,1,float_objective
|
| 51 |
+
ea_third_autocorrelation,optimize,research,analysis,EinsteinArena/third-autocorrelation-inequality,MIT,third_autocorrelation_inequality_upper,1,float_objective
|
| 52 |
+
ea_thomson_282,optimize,research,discrete_geometry,EinsteinArena/thomson-problem,MIT,thomson_problem_n282,1,float_objective
|
| 53 |
+
ea_two_deletion_code_16,optimize,research,coding_theory,EinsteinArena/two-deletion-code-16,MIT,two_deletion_code_n16,1,ea_under_review;exact_check
|
| 54 |
+
ea_uncertainty_principle,optimize,research,analysis,EinsteinArena/uncertainty-principle,MIT,plus1_uncertainty_principle_upper,1,high_precision
|
| 55 |
+
finch_3ap_diffs_40,optimize,research,combinatorics,Finch-EFT/skydiscover/erdos_1097_3ap_diffs_n40,Apache-2.0,erdos1097_3ap_differences_n40_m400,1,best_known_uncertain;exact_check;np_search
|
| 56 |
+
finch_4subset_3dist_16,optimize,research,discrete_geometry,Finch-EFT/skydiscover/erdos_659_4subset_3dist_construction,Apache-2.0,erdos659_4sets_3dist_n16,1,best_known_uncertain;exact_check;np_search
|
| 57 |
+
finch_flat_poly_32,optimize,research,analysis,Finch-EFT/skydiscover/erdos_flat_polynomials_n32,Apache-2.0,flat_littlewood_polynomial_n32,1,best_known_uncertain;float_objective;np_search
|
| 58 |
+
finch_heilbronn_disk_12,optimize,research,discrete_geometry,Finch-EFT/skydiscover/erdos_507_heilbronn_disk_n12,Apache-2.0,heilbronn_disk_n12,1,best_known_uncertain;exact_check;float_objective
|
| 59 |
+
finch_isosceles_free_grid_8,optimize,competition,discrete_geometry,Finch-EFT/skydiscover/erdos_isosceles_free_grid,Apache-2.0,isosceles_free_grid_subset,1,exact_check;exact_optimum_known;np_search
|
| 60 |
+
finch_lcm_chain_10000,optimize,competition,number_theory,Finch-EFT/skydiscover/erdos_440_lcm_density,Apache-2.0,erdos440_lcm_consecutive_x10000,1,exact_check;exact_optimum_known
|
| 61 |
+
finch_newman_200,optimize,research,number_theory,Finch-EFT/skydiscover/erdos_480_newman_density,Apache-2.0,erdos480_newman_finite_n200,1,best_known_uncertain;float_objective
|
| 62 |
+
finch_no4_concyclic_12,optimize,research,discrete_geometry,Finch-EFT/skydiscover/erdos_654_no_four_concyclic_distances,Apache-2.0,erdos654_no4_concyclic_n12,1,best_known_uncertain;exact_check;np_search
|
| 63 |
+
finch_sidon_pair_100,optimize,research,number_theory,Finch-EFT/skydiscover/erdos_43_sidon_pair,Apache-2.0,erdos43_sidon_pair_n100,1,best_known_uncertain;exact_check;np_search
|
| 64 |
+
finch_sidon_set_121,optimize,competition,number_theory,Finch-EFT/skydiscover/erdos_difference_bases_N121,Apache-2.0,max_sidon_set_0_120,1,exact_check;exact_optimum_known
|
| 65 |
+
finch_square_packing_12,optimize,research,discrete_geometry,Finch-EFT/skydiscover/erdos_106_square_packing,Apache-2.0,erdos106_squares_in_square_n12,1,exact_check
|
| 66 |
+
finch_udg_girth_30,optimize,research,graph_theory,Finch-EFT/skydiscover/erdos_705_unit_distance_high_girth,Apache-2.0,erdos705_udg_chi4_girth_n30,1,best_known_uncertain;exact_check
|
| 67 |
+
fs_admissible_set,optimize,research,combinatorics,FunSearch/admissible_set,Apache-2.0,admissible_set_constant_weight,2,integer_objective
|
| 68 |
+
fs_cap_set,optimize,research,combinatorics,FunSearch/cap_set,Apache-2.0,cap_set_f3n,6,integer_objective
|
| 69 |
+
fs_cycle_independent_set,optimize,research,graph_theory,FunSearch/cyclic_graphs,Apache-2.0,independent_set_strong_power_odd_cycle,7,integer_objective
|
| 70 |
+
mc_all_interval,construct,competition,combinatorics,MathConstraint/all_interval,CC-BY-4.0,all_interval_series,40,agentic_trivial
|
| 71 |
+
mc_antimagic_square,construct,competition,combinatorics,MathConstraint/antimagic_square,CC-BY-4.0,antimagic_square,6,np_search
|
| 72 |
+
mc_bibd,construct,competition,combinatorics,MathConstraint/bibd,CC-BY-4.0,bibd,28,np_search
|
| 73 |
+
mc_costas_array,construct,competition,combinatorics,MathConstraint/costas_array,CC-BY-4.0,costas_array,23,np_search
|
| 74 |
+
mc_debruijn,construct,competition,combinatorics,MathConstraint/debruijn,CC-BY-4.0,de_bruijn_sequence,22,agentic_trivial
|
| 75 |
+
mc_golomb,construct,competition,combinatorics,MathConstraint/golomb,CC-BY-4.0,golomb_ruler,18,np_search
|
| 76 |
+
mc_graceful_graph,construct,competition,graph_theory,MathConstraint/graceful_graph,CC-BY-4.0,graceful_labeling,17,np_search
|
| 77 |
+
mc_graph_k_coloring,construct,competition,graph_theory,MathConstraint/graph_k_coloring,CC-BY-4.0,graph_k_coloring,48,np_search
|
| 78 |
+
mc_hadamard,construct,competition,combinatorics,MathConstraint/hadamard,CC-BY-4.0,legendre_pair,30,np_search
|
| 79 |
+
mc_langford,construct,competition,combinatorics,MathConstraint/langford,CC-BY-4.0,langford_pairing,27,agentic_trivial;np_search
|
| 80 |
+
mc_low_autocorrelation,construct,competition,combinatorics,MathConstraint/low_autocorrelation,CC-BY-4.0,low_autocorrelation_binary_sequence,31,np_search
|
| 81 |
+
mc_magic_sequence,construct,competition,combinatorics,MathConstraint/magic_sequence,CC-BY-4.0,magic_sequence,30,agentic_trivial
|
| 82 |
+
mc_max_clique,construct,competition,graph_theory,MathConstraint/max_clique,CC-BY-4.0,graph_clique,55,np_search
|
| 83 |
+
mc_max_independent_set,construct,competition,graph_theory,MathConstraint/max_independent_set,CC-BY-4.0,graph_independent_set,60,np_search
|
| 84 |
+
mc_non_transitive_dice,construct,competition,probability,MathConstraint/non_transitive_dice,CC-BY-4.0,intransitive_dice,15,agentic_trivial;np_search
|
| 85 |
+
mc_number_partitioning,construct,competition,number_theory,MathConstraint/number_partitioning,CC-BY-4.0,equal_sum_partition_1_to_n,59,agentic_trivial
|
| 86 |
+
mc_ortholatin,construct,competition,combinatorics,MathConstraint/ortholatin,CC-BY-4.0,orthogonal_latin_squares,21,np_search
|
| 87 |
+
mc_pysms_chromatic_girth,construct,competition,graph_theory,MathConstraint/pysms_chromatic_girth,CC-BY-4.0,graph_existence_chromatic_girth,25,np_search
|
| 88 |
+
mc_pysms_clique_coloring,construct,competition,graph_theory,MathConstraint/pysms_clique_coloring,CC-BY-4.0,graph_existence_clique_coloring,16,np_search
|
| 89 |
+
mc_pysms_degree_bounds,construct,competition,graph_theory,MathConstraint/pysms_degree_bounds,CC-BY-4.0,graph_existence_degree_bounds,11,agentic_trivial;np_search
|
| 90 |
+
mc_pysms_girth_degree,construct,competition,graph_theory,MathConstraint/pysms_girth_degree,CC-BY-4.0,graph_existence_girth_degree,18,np_search
|
| 91 |
+
mc_pysms_graph_builder,construct,competition,graph_theory,MathConstraint/pysms_graph_builder,CC-BY-4.0,graph_existence_graph_builder,8,np_search
|
| 92 |
+
mc_pysms_independent_connectivity,construct,competition,graph_theory,MathConstraint/pysms_independent_connectivity,CC-BY-4.0,graph_existence_independent_connectivity,15,np_search
|
| 93 |
+
mc_pysms_min_connectivity,construct,competition,graph_theory,MathConstraint/pysms_min_connectivity,CC-BY-4.0,graph_existence_min_connectivity,12,agentic_trivial;np_search
|
| 94 |
+
mc_pysms_min_degree,construct,competition,graph_theory,MathConstraint/pysms_min_degree,CC-BY-4.0,graph_existence_min_degree,12,agentic_trivial;np_search
|
| 95 |
+
mc_pysms_min_girth,construct,competition,graph_theory,MathConstraint/pysms_min_girth,CC-BY-4.0,graph_existence_min_girth,13,agentic_trivial;np_search
|
| 96 |
+
mc_pysms_mtf,construct,competition,graph_theory,MathConstraint/pysms_mtf,CC-BY-4.0,maximal_triangle_free_graph,12,agentic_trivial;np_search
|
| 97 |
+
mc_pysms_num_edges_bounds,construct,competition,graph_theory,MathConstraint/pysms_num_edges_bounds,CC-BY-4.0,graph_existence_num_edges_bounds,12,agentic_trivial;np_search
|
| 98 |
+
mc_quasigroup_idempotent,construct,competition,algebra,MathConstraint/quasigroup_idempotent,CC-BY-4.0,idempotent_qg3_quasigroup,12,np_search
|
| 99 |
+
mc_ramsey,construct,competition,combinatorics,MathConstraint/ramsey,CC-BY-4.0,ramsey_two_colouring,54,np_search
|
| 100 |
+
mc_social_golfers,construct,competition,combinatorics,MathConstraint/social_golfers,CC-BY-4.0,social_golfer,23,np_search
|
| 101 |
+
mc_van_der_waerden,construct,competition,combinatorics,MathConstraint/van_der_waerden,CC-BY-4.0,van_der_waerden_colouring,42,np_search
|
| 102 |
+
mc_vertex_cover,construct,competition,graph_theory,MathConstraint/vertex_cover,CC-BY-4.0,graph_vertex_cover,60,np_search
|
| 103 |
+
nppc_bandwidth,construct,competition,graph_theory,NPPC/bandwidth,MIT,graph_bandwidth,60,agentic_trivial;np_search
|
| 104 |
+
nppc_clique,construct,competition,graph_theory,NPPC/clique,MIT,graph_clique,60,agentic_trivial;np_search
|
| 105 |
+
nppc_dominating_set,construct,competition,graph_theory,NPPC/dominating_set,MIT,graph_dominating_set,60,agentic_trivial;np_search
|
| 106 |
+
nppc_independent_set,construct,competition,graph_theory,NPPC/independent_set,MIT,graph_independent_set,60,agentic_trivial;np_search
|
| 107 |
+
nppc_quad_diophantine,construct,competition,number_theory,NPPC/quad_diop_equ,MIT,quadratic_diophantine_ax2_by_c,60,agentic_trivial;np_search
|
| 108 |
+
nppc_quadratic_congruence,construct,competition,number_theory,NPPC/quadratic_congruence,MIT,quadratic_congruence_bounded,60,agentic_trivial;np_search
|
| 109 |
+
nppc_three_coloring,construct,competition,graph_theory,NPPC/graph_three_colorability,MIT,graph_3_coloring,60,agentic_trivial;np_search
|
| 110 |
+
nppc_vertex_cover,construct,competition,graph_theory,NPPC/vertex_cover,MIT,graph_vertex_cover,60,agentic_trivial;np_search
|
| 111 |
+
rg_graph_color,construct,competition,graph_theory,ReasoningGym/graph_color,Apache-2.0,graph_k_coloring,60,agentic_trivial;np_search
|
| 112 |
+
rg_intermediate_integration,construct,competition,analysis,ReasoningGym/intermediate_integration,Apache-2.0,symbolic_antiderivative,60,symbolic
|
| 113 |
+
rg_simple_integration,construct,competition,analysis,ReasoningGym/simple_integration,Apache-2.0,symbolic_antiderivative_polynomial,60,symbolic
|
| 114 |
+
rlve_antiderivative,construct,competition,analysis,RLVE-Gym/integral,MIT,symbolic_antiderivative,60,
|
| 115 |
+
rlve_bezout_identity,construct,competition,number_theory,RLVE-Gym/bezout_identity,MIT,bezout_coefficients,60,agentic_trivial
|
| 116 |
+
rlve_construct_hack_interval,construct,competition,number_theory,RLVE-Gym/construct_hack_interval,MIT,cf468c_hack_interval,60,
|
| 117 |
+
rlve_crt,construct,competition,number_theory,RLVE-Gym/crt,MIT,generalized_crt,60,agentic_trivial
|
| 118 |
+
rlve_distinct_subset_sum_permutation,construct,competition,combinatorics,RLVE-Gym/distinct_array_permutation,MIT,cf892d_gluttony,60,agentic_trivial
|
| 119 |
+
rlve_even_degree_partition,construct,competition,graph_theory,RLVE-Gym/even_degree_graph_partitioning,MIT,gallai_even_partition,60,agentic_trivial
|
| 120 |
+
rlve_graph_isomorphism,construct,competition,graph_theory,RLVE-Gym/graph_isomorphism,MIT,graph_isomorphism,60,agentic_trivial;np_search
|
| 121 |
+
rlve_grid_parity_construction,construct,competition,algebra,RLVE-Gym/grid_parity_construction,MIT,lights_out_gf2,60,agentic_trivial
|
| 122 |
+
rlve_imp_party,construct,competition,graph_theory,RLVE-Gym/imp_party,MIT,poi_party_clique_3n,60,agentic_trivial
|
| 123 |
+
rlve_integer_linear_system,construct,competition,algebra,RLVE-Gym/gaussian_elimination,MIT,integer_linear_system,60,agentic_trivial
|
| 124 |
+
rlve_largest_convex_polygon,construct,competition,discrete_geometry,RLVE-Gym/largest_convex_polygon,MIT,largest_convex_subset,60,agentic_trivial
|
| 125 |
+
rlve_largest_rectangle,construct,competition,discrete_geometry,RLVE-Gym/largest_rectangle_among_points,MIT,largest_rectangle_in_point_set,60,agentic_trivial
|
| 126 |
+
rlve_matrix_permutation_equivalence,construct,competition,combinatorics,RLVE-Gym/matrix_permutation_equivalence,MIT,binary_matrix_permutation_equivalence,60,agentic_trivial;np_search
|
| 127 |
+
rlve_max_achromatic_coloring,construct,competition,graph_theory,RLVE-Gym/maximum_achromatic_number,MIT,achromatic_number,60,agentic_trivial;np_search
|
| 128 |
+
rlve_maximum_clique,construct,competition,graph_theory,RLVE-Gym/maximum_clique,MIT,maximum_clique,60,agentic_trivial;np_search
|
| 129 |
+
rlve_min_chromatic_number,construct,competition,graph_theory,RLVE-Gym/minimum_chromatic_number,MIT,graph_k_coloring_chromatic,60,agentic_trivial;np_search
|
| 130 |
+
rlve_min_harmonious_coloring,construct,competition,graph_theory,RLVE-Gym/minimum_harmonious_chromatic_number,MIT,harmonious_chromatic_number,60,agentic_trivial;np_search
|
| 131 |
+
rlve_pairwise_sums_recovery,construct,competition,combinatorics,RLVE-Gym/squ_squarks,MIT,poi_squarks_pairwise_sums,60,agentic_trivial
|
| 132 |
+
rlve_pan_solar_panels,construct,competition,number_theory,RLVE-Gym/pan_solar_panels,MIT,poi_solar_panels_max_gcd,60,agentic_trivial
|
| 133 |
+
rlve_polynomial_global_minimum,construct,competition,analysis,RLVE-Gym/polynomial_minimum,MIT,polynomial_global_minimum,60,agentic_trivial
|
| 134 |
+
rlve_polynomial_integer_roots,construct,competition,algebra,RLVE-Gym/polynomial_factorization,MIT,integer_root_factorization,60,agentic_trivial;unique_answer
|
| 135 |
+
rlve_polynomial_interpolation,construct,competition,algebra,RLVE-Gym/polynomial_interpolation,MIT,lagrange_interpolation_integer,60,agentic_trivial;unique_answer
|
| 136 |
+
rlve_prefix_product_permutation,construct,competition,number_theory,RLVE-Gym/prefix_product_mod_distinct_permutation,MIT,cf487c_prefix_product_sequence,60,
|
| 137 |
+
rlve_prefix_sum_permutation,construct,competition,number_theory,RLVE-Gym/prefix_sum_mod_distinct_permutation,MIT,prefix_sum_mod_distinct_permutation,60,
|
| 138 |
+
rlve_prime_graph_coloring,construct,competition,graph_theory,RLVE-Gym/prime_graph_minimum_chromatic_number,MIT,prime_distance_graph_coloring,60,agentic_trivial
|
| 139 |
+
rlve_recursive_sequence_sum,construct,competition,number_theory,RLVE-Gym/recursive_sequence_sum_construction,MIT,linear_recurrence_subset_sum,60,agentic_trivial
|
| 140 |
+
rlve_round_robin_scores,construct,competition,combinatorics,RLVE-Gym/round_robin,MIT,tournament_score_realisation_3_1_0,60,agentic_trivial
|
| 141 |
+
rlve_shortest_path_count,construct,competition,combinatorics,RLVE-Gym/shortest_path_count_construction,MIT,cf388b_shortest_path_count,60,
|
| 142 |
+
rlve_smallest_enclosing_circle,construct,competition,geometry,RLVE-Gym/smallest_circle,MIT,minimum_enclosing_circle,60,agentic_trivial
|
| 143 |
+
rlve_subgraph_isomorphism,construct,competition,graph_theory,RLVE-Gym/subgraph_isomorphism,MIT,induced_subgraph_isomorphism,60,agentic_trivial;np_search
|
| 144 |
+
ae_p14_hausdorff_young,optimize,research,analysis,AlphaEvolve-Repository-of-Problems/14-hausdorff-young,CC-BY-4.0,hausdorff_young_sharp_constant,2,float_objective;known_optimum
|
| 145 |
+
ae_p1_ff_nikodym_2d,optimize,research,combinatorics,AlphaEvolve-Repository-of-Problems/1-finite-field-nikodym,CC-BY-4.0,finite_field_nikodym_min_size_d2_q_square,3,best_known_uncertain;exact_integer;finite_fields
|
| 146 |
+
ae_p33_thomson,optimize,research,discrete_geometry,AlphaEvolve-Repository-of-Problems/33-thomson-problem,CC-BY-4.0,thomson_problem,2,best_known_uncertain;float_objective
|
| 147 |
+
ae_p35_hexagons_in_hexagon,optimize,research,discrete_geometry,AlphaEvolve-Repository-of-Problems/35-packing-in-a-dilate,CC-BY-4.0,unit_hexagons_in_smallest_hexagon,2,float_objective;packing
|
| 148 |
+
ae_p40_erdos_discrepancy_c3,optimize,research,combinatorics,AlphaEvolve-Repository-of-Problems/40-erdos-discrepancy,CC-BY-4.0,erdos_discrepancy_C3_max_length,1,best_known_uncertain;exact_integer;np_search;sat_friendly
|
| 149 |
+
ae_p56_szemeredi_trotter,optimize,research,combinatorics,AlphaEvolve-Repository-of-Problems/56-szemeredi-trotter,CC-BY-4.0,point_line_incidences_integer_n_eq_m,3,best_known_uncertain;exact_integer;incidence_geometry
|
| 150 |
+
ae_p57_rudin_l4,optimize,research,analysis,AlphaEvolve-Repository-of-Problems/57-rudin-problem,CC-BY-4.0,flat_spherical_harmonic_l4_l2_s2,3,best_known_uncertain;float_objective
|
| 151 |
+
ale_ahc002,optimize,competition,combinatorics,ALE-Bench/ahc002,CC-BY-ND-4.0,ale_ahc002,2,ale_bench;best_known_uncertain;exact_integer;license_restricted;np_search
|
| 152 |
+
ale_ahc004,optimize,competition,combinatorics,ALE-Bench/ahc004,CC-BY-ND-4.0,ale_ahc004,2,ale_bench;best_known_uncertain;exact_integer;license_restricted;np_search
|
| 153 |
+
ale_ahc009,optimize,competition,probability,ALE-Bench/ahc009,CC-BY-ND-4.0,ale_ahc009,2,ale_bench;best_known_uncertain;float_objective;license_restricted;np_search
|
| 154 |
+
ale_ahc010,optimize,competition,combinatorics,ALE-Bench/ahc010,CC-BY-ND-4.0,ale_ahc010,2,ale_bench;best_known_uncertain;exact_integer;license_restricted;np_search
|
| 155 |
+
ale_ahc011,optimize,competition,combinatorics,ALE-Bench/ahc011,CC-BY-ND-4.0,ale_ahc011,2,ale_bench;best_known_uncertain;exact_integer;license_restricted;np_search
|
| 156 |
+
ale_ahc014,optimize,competition,discrete_geometry,ALE-Bench/ahc014,CC-BY-ND-4.0,ale_ahc014,2,ale_bench;best_known_uncertain;exact_integer;license_restricted;np_search
|
| 157 |
+
ale_ahc017,optimize,competition,graph_theory,ALE-Bench/ahc017,CC-BY-ND-4.0,ale_ahc017,2,ale_bench;best_known_uncertain;exact_integer;license_restricted;np_search
|
| 158 |
+
ale_ahc019,optimize,competition,discrete_geometry,ALE-Bench/ahc019,CC-BY-ND-4.0,ale_ahc019,2,ale_bench;best_known_uncertain;exact_integer;license_restricted;np_search
|
| 159 |
+
ale_ahc021,optimize,competition,combinatorics,ALE-Bench/ahc021,CC-BY-ND-4.0,ale_ahc021,2,ale_bench;best_known_uncertain;exact_integer;license_restricted;np_search
|
| 160 |
+
ale_ahc024,optimize,competition,graph_theory,ALE-Bench/ahc024,CC-BY-ND-4.0,ale_ahc024,2,ale_bench;best_known_uncertain;exact_integer;license_restricted;np_search
|
| 161 |
+
ale_ahc026,optimize,competition,combinatorics,ALE-Bench/ahc026,CC-BY-ND-4.0,ale_ahc026,2,ale_bench;best_known_uncertain;exact_integer;license_restricted;np_search
|
| 162 |
+
ale_ahc032,optimize,competition,number_theory,ALE-Bench/ahc032,CC-BY-ND-4.0,ale_ahc032,2,ale_bench;best_known_uncertain;exact_integer;license_restricted;np_search
|
| 163 |
+
ale_ahc038,optimize,competition,other,ALE-Bench/ahc038,CC-BY-ND-4.0,ale_ahc038,2,ale_bench;best_known_uncertain;exact_integer;license_restricted;np_search
|
| 164 |
+
ale_ahc039,optimize,competition,discrete_geometry,ALE-Bench/ahc039,CC-BY-ND-4.0,ale_ahc039,2,ale_bench;best_known_uncertain;exact_integer;license_restricted;np_search
|
| 165 |
+
ale_ahc041,optimize,competition,graph_theory,ALE-Bench/ahc041,CC-BY-ND-4.0,ale_ahc041,2,ale_bench;best_known_uncertain;exact_integer;license_restricted;np_search
|
| 166 |
+
ale_ahc042,optimize,competition,combinatorics,ALE-Bench/ahc042,CC-BY-ND-4.0,ale_ahc042,2,ale_bench;best_known_uncertain;exact_integer;license_restricted;np_search
|
| 167 |
+
ale_ahc044,optimize,competition,combinatorics,ALE-Bench/ahc044,CC-BY-ND-4.0,ale_ahc044,2,ale_bench;best_known_uncertain;exact_integer;license_restricted;np_search
|
| 168 |
+
ale_ahc046,optimize,competition,combinatorics,ALE-Bench/ahc046,CC-BY-ND-4.0,ale_ahc046,2,ale_bench;best_known_uncertain;exact_integer;license_restricted;np_search
|
| 169 |
+
edge_apple_incremental,optimize,competition,combinatorics,EdgeBench/apple_incremental_game (AHC058),CC-BY-4.0,edge_ahc058_apple_incremental,2,best_known_uncertain;derived_from_atcoder;edgebench;exact_integer;np_search
|
| 170 |
+
edge_grid_turing_robot,optimize,competition,combinatorics,EdgeBench/grid_turing_robot (AHC056),CC-BY-4.0,edge_ahc056_grid_turing_robot,2,best_known_uncertain;derived_from_atcoder;edgebench;exact_integer;np_search
|
| 171 |
+
fco_mds,optimize,competition,graph_theory,FrontierCO/MDS (CO-Bench/FrontierCO),MIT,frontierco_mds,15,agentic_trivial;best_known_uncertain;exact_integer;frontierco;known_optimum;np_search;related_training:nppc_dominating_set
|
| 172 |
+
fcs_beacon,optimize,competition,combinatorics,FrontierCS/algorithmic/302,MIT,fcs_beacon_string_penalty,3,best_known_uncertain;exact_integer;frontiercs;np_search
|
| 173 |
+
fcs_digit_grid,optimize,competition,combinatorics,FrontierCS/algorithmic/110,MIT,fcs_digit_grid_8x14,1,exact_integer;frontiercs;np_search
|
| 174 |
+
fcs_gcd_chain,optimize,competition,number_theory,FrontierCS/algorithmic/41,MIT,fcs_gcd_increasing_chain_ksum,3,best_known_uncertain;exact_integer;frontiercs
|
| 175 |
+
fcs_inc_subseq_perm,optimize,competition,combinatorics,FrontierCS/algorithmic/33,MIT,fcs_perm_exact_increasing_subsequences,2,exact_integer;frontiercs
|
| 176 |
+
fcs_inverse_paths,optimize,competition,combinatorics,FrontierCS/algorithmic/58,MIT,fcs_inverse_counting_path,3,best_known_uncertain;exact_integer;frontiercs
|
| 177 |
+
fcs_lis_lds_split,optimize,competition,combinatorics,FrontierCS/algorithmic/227,MIT,fcs_lis_lds_four_split,3,best_known_uncertain;exact_integer;frontiercs
|
| 178 |
+
fcs_max3sat,optimize,competition,combinatorics,FrontierCS/algorithmic/176,MIT,fcs_max3sat,3,best_known_uncertain;exact_integer;frontiercs;np_search
|
| 179 |
+
fcs_maxcut,optimize,competition,graph_theory,FrontierCS/algorithmic/192,MIT,fcs_maxcut,3,best_known_uncertain;exact_integer;frontiercs;np_search
|
| 180 |
+
fcs_mult_partial_sums,optimize,competition,number_theory,FrontierCS/algorithmic/83,MIT,completely_multiplicative_min_partial_sum_n1e6,1,exact_integer;frontiercs;related_training:ae_p40_erdos_discrepancy
|
| 181 |
+
fcs_no_rectangle,optimize,competition,combinatorics,FrontierCS/algorithmic/27,MIT,fcs_no_rectangle,3,best_known_uncertain;exact_integer;frontiercs;np_search;zarankiewicz
|
| 182 |
+
fcs_prime_retune,optimize,competition,combinatorics,FrontierCS/algorithmic/314,MIT,fcs_prime_resonance_retuning,3,best_known_uncertain;exact_integer;frontiercs;np_search
|
| 183 |
+
fcs_shortcut3hop,optimize,competition,graph_theory,FrontierCS/algorithmic/239,MIT,fcs_path_shortcut_hop3,3,exact_integer;frontiercs
|
| 184 |
+
fcs_swap_shift,optimize,competition,combinatorics,FrontierCS/algorithmic/247,MIT,fcs_swap_shift_min_ops,3,exact_integer;frontiercs
|
| 185 |
+
fcs_xor_sidon,optimize,competition,combinatorics,FrontierCS/algorithmic/111,MIT,fcs_xor_sidon,3,best_known_uncertain;exact_integer;frontiercs;np_search
|
| 186 |
+
fsh_abc_quality,optimize,research,number_theory,FrontierShift/fs-0375,unknown,abc_triple_max_quality,1,exact_check;float_objective;frontiershift;license_unknown;record_memorizable
|
| 187 |
+
fsh_boolean_nonlinearity_9,optimize,research,coding_theory,FrontierShift/fs-0243,unknown,boolean_function_max_nonlinearity_n9,1,exact_integer;frontiershift;license_unknown;np_search;reference_below_best_known
|
| 188 |
+
fsh_cramer_gap_ratio,optimize,research,number_theory,FrontierShift/fs-0377,unknown,prime_gap_cramer_shanks_granville_ratio_p_lt_2pow64,1,exact_check;float_objective;frontiershift;known_optimum;license_unknown;record_memorizable
|
| 189 |
+
fsh_lwc_1280,optimize,research,coding_theory,FrontierShift/fs-0364 (decodingchallenge.org LW n=1280 seed 0),unknown,decoding_challenge_low_weight_codeword_n1280_seed0,1,cryptography;exact_check;frontiershift;license_unknown;np_search
|
| 190 |
+
fsh_matmul_rank,optimize,research,algebra,"FrontierShift/fs-0034,fs-0035",unknown,matmul_tensor_rank_nnn_over_Q,2,exact_check;exact_rational;frontiershift;license_unknown;record_memorizable;tensor_decomposition
|
| 191 |
+
fsh_maxdet_23,optimize,research,combinatorics,FrontierShift/fs-0164,unknown,hadamard_maxdet_n23,1,best_known_uncertain;exact_integer;frontiershift;license_unknown;np_search
|
| 192 |
+
fsh_rational_diophantine_7,optimize,research,number_theory,FrontierShift/fs-0395,unknown,rational_diophantine_septuple_square_pairs,1,exact_check;exact_rational;frontiershift;license_unknown;reference_below_best_known
|
| 193 |
+
fsh_tetrahedra_packing,optimize,research,discrete_geometry,FrontierShift/fs-0247,unknown,regular_tetrahedra_periodic_packing_density,1,best_known_is_open_target;exact_check;exact_rational;float_objective;frontiershift;license_unknown;reference_below_best_known
|
| 194 |
+
lib_cage,optimize,research,graph_theory,LeapsInBounds/cage,MIT,cage_order_k_g,8,exact_check;exact_integer;leaps_in_bounds;np_search;reference_below_record
|
| 195 |
+
lib_circle_in_square,optimize,research,discrete_geometry,LeapsInBounds/circle-in-square,MIT,equal_circles_in_square_min_side_n,6,best_known_uncertain;exact_check;float_objective;known_optimum;leaps_in_bounds
|
| 196 |
+
lib_circle_in_triangle,optimize,research,discrete_geometry,LeapsInBounds/circle-in-equilateral,MIT,equal_circles_in_equilateral_triangle_min_side_n,3,exact_check;float_objective;known_optimum;leaps_in_bounds
|
| 197 |
+
lib_coil_in_the_box,optimize,research,graph_theory,LeapsInBounds/coil-in-the-box,MIT,coil_in_the_box_dn,5,exact_check;exact_integer;leaps_in_bounds;np_search
|
| 198 |
+
lib_degree_diameter,optimize,research,graph_theory,LeapsInBounds/degree-diameter,MIT,degree_diameter_max_order_d_k,8,exact_check;exact_integer;leaps_in_bounds;np_search
|
| 199 |
+
lib_disk_covering,optimize,research,discrete_geometry,LeapsInBounds/disk-covering,MIT,unit_disk_covering_by_n_disks_min_radius,5,exact_check;exact_rational;float_objective;leaps_in_bounds;reference_below_record
|
| 200 |
+
lib_golomb_ruler,optimize,research,combinatorics,LeapsInBounds/golomb-ruler,MIT,golomb_ruler_min_length_n,7,exact_check;exact_integer;known_optimum;leaps_in_bounds;np_search
|
| 201 |
+
lib_isosceles_set,optimize,research,discrete_geometry,LeapsInBounds/isosceles-set,MIT,isosceles_set_max_size_rn,2,exact_check;exact_integer;known_optimum;leaps_in_bounds
|
| 202 |
+
lib_no_three_in_line,optimize,research,discrete_geometry,LeapsInBounds/no-three-in-line,MIT,no_three_in_line_grid_n,6,exact_check;exact_integer;known_optimum;leaps_in_bounds;np_search
|
| 203 |
+
lib_snake_in_the_box,optimize,research,graph_theory,LeapsInBounds/snake-in-the-box,MIT,snake_in_the_box_dn,4,exact_check;exact_integer;leaps_in_bounds;np_search
|
| 204 |
+
lib_sorting_network_depth,optimize,research,combinatorics,LeapsInBounds/sorting-network-depth,MIT,sorting_network_depth_n,8,exact_check;exact_integer;leaps_in_bounds;np_search
|
| 205 |
+
lib_sorting_network_size,optimize,research,combinatorics,LeapsInBounds/sorting-network-size,MIT,sorting_network_size_n,8,exact_check;exact_integer;leaps_in_bounds;np_search
|
| 206 |
+
lib_square_packing,optimize,research,discrete_geometry,LeapsInBounds/square-packing,MIT,unit_squares_in_square_min_side_n,8,exact_check;exact_rational;float_objective;leaps_in_bounds;reference_is_baseline
|
| 207 |
+
lib_superpermutation,optimize,research,combinatorics,LeapsInBounds/minimal-superpermutation,MIT,minimal_superpermutation_n,4,exact_check;exact_integer;leaps_in_bounds;reference_below_record
|
| 208 |
+
tao_c15a_matmul_rank_exponent,optimize,research,algebra,TaoOptimizationConstants/15a,Apache-2.0,matmul_exponent_exact_rank_formats_le6,1,best_known_uncertain;exact_check;exact_integer;float_objective;tao_constants
|
| 209 |
+
tao_c16a_brezis_gallouet_wainger,optimize,research,analysis,TaoOptimizationConstants/16a,Apache-2.0,brezis_gallouet_wainger_torus_L_radial_shell_le40000,1,agentic_trivial;float_objective;reference_not_record;tao_constants
|
| 210 |
+
tao_c19a_berry_esseen,optimize,research,probability,TaoOptimizationConstants/19a,Apache-2.0,berry_esseen_lower_bound_lattice_n_le10000,1,agentic_trivial;best_known_asymptotic;float_objective;reference_not_record;tao_constants
|
| 211 |
+
tao_c24a_komlos_discrepancy,optimize,research,combinatorics,TaoOptimizationConstants/24a,Apache-2.0,komlos_discrepancy_lower_bound_m_le40_n_le20,1,exact_check;exact_integer;np_search;reference_not_record;tao_constants
|
| 212 |
+
tao_c26a_boolean_bohnenblust_hille,optimize,research,analysis,TaoOptimizationConstants/26a,Apache-2.0,boolean_bohnenblust_hille_ratio_n_le20,1,best_known_asymptotic;exact_integer;float_objective;reference_not_record;tao_constants
|
| 213 |
+
tao_c27b_biplanar_chromatic,optimize,research,graph_theory,TaoOptimizationConstants/27b,Apache-2.0,biplanar_max_chromatic_number_n_le32,1,exact_check;exact_integer;known_record_small;tao_constants
|
| 214 |
+
tao_c37a_degree_sensitivity,optimize,research,combinatorics,TaoOptimizationConstants/37a,Apache-2.0,degree_sensitivity_exponent_n_le16,1,exact_check;float_objective;tao_constants
|
| 215 |
+
tao_c40a_lehmer_mahler,optimize,research,number_theory,TaoOptimizationConstants/40a,Apache-2.0,lehmer_min_mahler_measure_gt1_deg_le64,1,agentic_trivial;exact_check;float_objective;tao_constants
|
| 216 |
+
tao_c49a_sunflower_free,optimize,research,combinatorics,Tao-Davis-Ivanisvili Optimization Constants/49a (sunflower-free capacity),Apache-2.0,sperner_sunflower_free_family_max_size,2,best_known_uncertain;exact_integer;np_search;tao_constants
|
| 217 |
+
tao_c71a_fei_ratio,optimize,research,combinatorics,Tao-Davis-Ivanisvili Optimization Constants/71a (Fourier Entropy-Influence),Apache-2.0,fei_constant_lower_bound_balanced_amplification,1,exact_check;float_objective;np_search;tao_constants
|
| 218 |
+
tao_c73a_hollow_lattice_width,optimize,research,discrete_geometry,Tao-Davis-Ivanisvili Optimization Constants/73a (flatness constant in dimension 3),Apache-2.0,hollow_convex_body_max_lattice_width_d3,1,exact_check;exact_rational;tao_constants
|
| 219 |
+
tao_c88a_admissible_tuple,optimize,research,number_theory,Tao-Davis-Ivanisvili Optimization Constants/88a (bounded prime gaps),Apache-2.0,narrowest_admissible_k_tuple,4,agentic_trivial;best_known_uncertain;exact_integer;known_optimum;np_search;tao_constants
|
| 220 |
+
tao_c90a_covering_min_modulus,optimize,research,number_theory,Tao-Davis-Ivanisvili Optimization Constants/90a (covering systems),Apache-2.0,distinct_covering_system_min_modulus_lcm_le_1e8,1,exact_integer;np_search;record_outside_answer_class;tao_constants
|
graders/ae_p14_hausdorff_young/check.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Hausdorff-Young quotient ||f^||_{p'} / ||f||_p for real step functions, p' = 2k an even integer.
|
| 2 |
+
|
| 3 |
+
f = sum_i h_i 1_[i, i+1) (unit steps, real heights), Fourier transform f^(xi) = int f(x) e^{-2 pi i x xi} dx.
|
| 4 |
+
For p' = 2k, (f^)^k is the transform of the k-fold self-convolution f^{*k}, so by Plancherel
|
| 5 |
+
||f^||_{2k}^{2k} = ||f^{*k}||_2^2,
|
| 6 |
+
and f^{*k} = sum_j c_j B_k(x - j) with c = h^{*k} (discrete convolution) and B_k the order-k cardinal B-spline
|
| 7 |
+
(the k-fold convolution of 1_[0,1)). Hence ||f^{*k}||_2^2 = sum_d M_k(d) sum_j c_j c_{j+d} with
|
| 8 |
+
M_k(d) = int B_k(x) B_k(x + d) dx = (centred order-2k B-spline at d): k=2 -> 2/3, 1/6; k=3 -> 11/20, 13/60, 1/120.
|
| 9 |
+
Everything is a finite sum (float64). Upstream (classical_inequalities.ipynb, p = 3/2) truncated the
|
| 10 |
+
Fourier integral to [-R2, R2] and integrated it by Gaussian quadrature on a fixed 200-point grid; for even p'
|
| 11 |
+
the closed form above replaces that.
|
| 12 |
+
"""
|
| 13 |
+
import numpy as np
|
| 14 |
+
|
| 15 |
+
from run import Invalid, float_list
|
| 16 |
+
|
| 17 |
+
M = {2: (2.0 / 3.0, 1.0 / 6.0), 3: (11.0 / 20.0, 13.0 / 60.0, 1.0 / 120.0)}
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def check(inst, ans):
|
| 21 |
+
k, p = inst["k"], inst["p"]
|
| 22 |
+
h = ans.get("heights")
|
| 23 |
+
if not isinstance(h, list) or not 1 <= len(h) <= inst["max_len"]:
|
| 24 |
+
raise Invalid(f"heights must be a list of 1..{inst['max_len']} numbers")
|
| 25 |
+
h = np.array(float_list(h, None, "heights"))
|
| 26 |
+
a = np.abs(h)
|
| 27 |
+
if a.max() > 1e6:
|
| 28 |
+
raise Invalid("entries must lie in [-1e6, 1e6]")
|
| 29 |
+
if a.max() == 0:
|
| 30 |
+
raise Invalid("f must not be identically zero")
|
| 31 |
+
h = h / a.max()
|
| 32 |
+
c = h
|
| 33 |
+
for _ in range(k - 1):
|
| 34 |
+
c = np.convolve(c, h)
|
| 35 |
+
w = M[k]
|
| 36 |
+
l2 = w[0] * float(np.dot(c, c)) + 2 * sum(w[d] * float(np.dot(c[:-d], c[d:])) for d in range(1, k)
|
| 37 |
+
if d < len(c))
|
| 38 |
+
if not l2 > 0:
|
| 39 |
+
raise Invalid("degenerate function")
|
| 40 |
+
lp = float(np.sum(np.abs(h) ** p))
|
| 41 |
+
q = l2 ** (1.0 / (2 * k)) / lp ** (1.0 / p)
|
| 42 |
+
return q, {"fhat_norm": l2 ** (1.0 / (2 * k)), "f_norm": lp ** (1.0 / p)}
|
graders/ae_p1_ff_nikodym_2d/check.py
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Finite-field Nikodym set N in F_q^2, q = p^2, submitted as its complement. Score = |N| (minimize).
|
| 2 |
+
|
| 3 |
+
F_q = F_p(w) with w^2 = k (k = inst["nonresidue"], the least quadratic non-residue mod p); the element a + b w
|
| 4 |
+
is written [a, b]. A point is [[x_a, x_b], [y_a, y_b]]. Every point P of F_q^2 needs a direction v != 0 such
|
| 5 |
+
that P + t v lies in N for all t in F_q, t != 0 (P itself may lie outside N). All q + 1 directions
|
| 6 |
+
(1, m), m in F_q, and (0, 1) are checked, vectorised over all q^2 points: a line {P + t v} is labelled by
|
| 7 |
+
the invariant v_y * x - v_x * y in F_q. Upstream (finite_field_nikodym.ipynb, 2D experiments) returned N
|
| 8 |
+
itself as an array; here the complement list must be duplicate-free and in range.
|
| 9 |
+
"""
|
| 10 |
+
import numpy as np
|
| 11 |
+
|
| 12 |
+
from run import Invalid, int_list
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def check(inst, ans):
|
| 16 |
+
p, k = inst["p"], inst["nonresidue"]
|
| 17 |
+
q = p * p
|
| 18 |
+
rem = ans.get("removed")
|
| 19 |
+
if not isinstance(rem, list):
|
| 20 |
+
raise Invalid("removed must be a list")
|
| 21 |
+
if len(rem) >= q * q:
|
| 22 |
+
raise Invalid("cannot remove every point")
|
| 23 |
+
codes = []
|
| 24 |
+
for pt in rem:
|
| 25 |
+
if not isinstance(pt, list) or len(pt) != 2:
|
| 26 |
+
raise Invalid("each point must be [[x_a, x_b], [y_a, y_b]]")
|
| 27 |
+
(xa, xb), (ya, yb) = int_list(pt[0], 2, 0, p - 1, "x"), int_list(pt[1], 2, 0, p - 1, "y")
|
| 28 |
+
codes.append(((xa * p + xb) * p + ya) * p + yb)
|
| 29 |
+
codes = np.array(codes, dtype=np.int64)
|
| 30 |
+
if len(np.unique(codes)) != len(codes):
|
| 31 |
+
raise Invalid("duplicate removed points")
|
| 32 |
+
in_n = np.ones(q * q, dtype=bool)
|
| 33 |
+
in_n[codes] = False
|
| 34 |
+
idx = np.arange(q * q)
|
| 35 |
+
xa, xb, ya, yb = idx // (p ** 3), (idx // (p * p)) % p, (idx // p) % p, idx % p
|
| 36 |
+
need = q - 1 + in_n.astype(np.int64) # points of N on the line through P, other than P
|
| 37 |
+
good = np.zeros(q * q, dtype=bool)
|
| 38 |
+
# direction (0, 1): invariant = x
|
| 39 |
+
dirs = [None] + [(ma, mb) for ma in range(p) for mb in range(p)]
|
| 40 |
+
for d in dirs:
|
| 41 |
+
if d is None:
|
| 42 |
+
lid = xa * p + xb
|
| 43 |
+
else: # direction (1, m): invariant = m*x - y
|
| 44 |
+
ma, mb = d
|
| 45 |
+
ra = (ma * xa + k * mb * xb - ya) % p
|
| 46 |
+
rb = (ma * xb + mb * xa - yb) % p
|
| 47 |
+
lid = ra * p + rb
|
| 48 |
+
cnt = np.bincount(lid[in_n], minlength=q)
|
| 49 |
+
good |= cnt[lid] == need
|
| 50 |
+
if good.all():
|
| 51 |
+
break
|
| 52 |
+
if not good.all():
|
| 53 |
+
i = int(np.flatnonzero(~good)[0])
|
| 54 |
+
raise Invalid(f"point {[[int(xa[i]), int(xb[i])], [int(ya[i]), int(yb[i])]]} lies on no punctured "
|
| 55 |
+
f"line inside N")
|
| 56 |
+
size = q * q - len(rem)
|
| 57 |
+
return size, {"size": size}
|
graders/ae_p33_thomson/check.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Thomson problem (AlphaEvolve problem 33): minimize the Coulomb energy of n points on the unit sphere S^2.
|
| 2 |
+
|
| 3 |
+
Same objective as the upstream get_score (thomson_problem.ipynb): vectors are projected onto the sphere and
|
| 4 |
+
E = sum_{i<j} 1/|p_i - p_j|. Changes: zero / non-finite vectors are rejected instead of being normalized to
|
| 5 |
+
NaN, and coincident points (distance < 1e-12) are rejected instead of being clamped to 1e-12.
|
| 6 |
+
"""
|
| 7 |
+
import numpy as np
|
| 8 |
+
|
| 9 |
+
from run import Invalid, float_matrix
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
def check(inst, ans):
|
| 13 |
+
n = inst["n"]
|
| 14 |
+
v = np.array(float_matrix(ans.get("vectors"), n, 3, "vectors"))
|
| 15 |
+
nr = np.linalg.norm(v, axis=1, keepdims=True)
|
| 16 |
+
if not np.all(np.isfinite(nr)) or np.any(nr < 1e-9) or np.any(nr > 1e9):
|
| 17 |
+
raise Invalid("each vector must have norm in [1e-9, 1e9]")
|
| 18 |
+
v = v / nr
|
| 19 |
+
d = np.sqrt(((v[:, None, :] - v[None, :, :]) ** 2).sum(-1))[np.triu_indices(n, 1)]
|
| 20 |
+
if d.min() < 1e-12:
|
| 21 |
+
raise Invalid("two points coincide")
|
| 22 |
+
e = float(np.sum(1.0 / d))
|
| 23 |
+
if not np.isfinite(e):
|
| 24 |
+
raise Invalid("non-finite energy")
|
| 25 |
+
return e, {"min_distance": float(d.min())}
|
graders/ae_p35_hexagons_in_hexagon/check.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Packing n unit regular hexagons in the smallest regular hexagon (AlphaEvolve problem 35, P = hexagon).
|
| 2 |
+
|
| 3 |
+
Inner hexagon i: centre (x_i, y_i), rotation a_i (degrees), vertices (x_i + cos(a_i + 60k), y_i + sin(a_i + 60k)),
|
| 4 |
+
k = 0..5 (side length 1). Disjoint interiors are checked with the separating-axis theorem over the 6 edge
|
| 5 |
+
normals of the two hexagons; the projections may overlap by at most inst["tol"] (floating-point slack, also
|
| 6 |
+
stated in the prompt). The outer hexagon has a given centre c and rotation b (degrees); the score is the
|
| 7 |
+
SMALLEST side s for which it contains every inner vertex, s = max_v max_k <v - c, u_k> / (sqrt(3)/2) with
|
| 8 |
+
u_k = (cos(b + 30 + 60k), sin(b + 30 + 60k)) the outer edge normals (exact containment, no tolerance).
|
| 9 |
+
Upstream (alphaevolve_results B.7) took the outer side as an input and checked containment with a
|
| 10 |
+
cross-product sign test; here it is computed, so a too-small claimed side cannot be submitted.
|
| 11 |
+
"""
|
| 12 |
+
import math
|
| 13 |
+
|
| 14 |
+
import numpy as np
|
| 15 |
+
|
| 16 |
+
from run import Invalid, float_list, float_matrix
|
| 17 |
+
|
| 18 |
+
ANG = np.deg2rad(60.0 * np.arange(6))
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def check(inst, ans):
|
| 22 |
+
n, tol = inst["n"], inst["tol"]
|
| 23 |
+
H = np.array(float_matrix(ans.get("hexagons"), n, 3, "hexagons"))
|
| 24 |
+
o = float_list(ans.get("outer"), 3, "outer")
|
| 25 |
+
if np.abs(H).max() > 1e4 or max(abs(t) for t in o) > 1e4:
|
| 26 |
+
raise Invalid("coordinates and angles must lie in [-1e4, 1e4]")
|
| 27 |
+
a = np.deg2rad(H[:, 2])[:, None] + ANG[None, :]
|
| 28 |
+
V = np.stack([H[:, 0:1] + np.cos(a), H[:, 1:2] + np.sin(a)], axis=-1) # (n, 6, 2)
|
| 29 |
+
nrm = np.stack([np.cos(a[:, :3] + math.pi / 6), np.sin(a[:, :3] + math.pi / 6)], axis=-1) # (n, 3, 2)
|
| 30 |
+
for i in range(n):
|
| 31 |
+
for j in range(i + 1, n):
|
| 32 |
+
if np.hypot(*(H[i, :2] - H[j, :2])) >= 2.0 + 1e-9: # circumcircles disjoint
|
| 33 |
+
continue
|
| 34 |
+
axes = np.concatenate([nrm[i], nrm[j]]) # (6, 2)
|
| 35 |
+
pi_, pj = V[i] @ axes.T, V[j] @ axes.T # (6, 6): vertex x axis
|
| 36 |
+
ov = np.minimum(pi_.max(0), pj.max(0)) - np.maximum(pi_.min(0), pj.min(0))
|
| 37 |
+
if ov.min() > tol:
|
| 38 |
+
raise Invalid(f"hexagons {i} and {j} overlap")
|
| 39 |
+
b = math.radians(o[2])
|
| 40 |
+
u = np.stack([np.cos(b + math.pi / 6 + ANG), np.sin(b + math.pi / 6 + ANG)], axis=-1) # (6, 2)
|
| 41 |
+
P = V.reshape(-1, 2) - np.array(o[:2])
|
| 42 |
+
s = float((P @ u.T).max() / (math.sqrt(3) / 2))
|
| 43 |
+
return s, {"outer_side": s}
|
graders/ae_p40_erdos_discrepancy_c3/check.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Erdos discrepancy problem, C = 3 (AlphaEvolve problem 40, new parameter): longest +-1 sequence of
|
| 2 |
+
discrepancy <= 3. Exact integer check of every homogeneous progression d, 2d, ..., kd <= n.
|
| 3 |
+
|
| 4 |
+
Upstream (erdos_discrepancy_problem.ipynb, C = 2) scored the longest good prefix plus a fractional bonus
|
| 5 |
+
1/(violations + 1); here the whole submitted sequence must have discrepancy <= C and the score is its length.
|
| 6 |
+
"""
|
| 7 |
+
import numpy as np
|
| 8 |
+
|
| 9 |
+
from run import Invalid, int_list
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
def check(inst, ans):
|
| 13 |
+
x = ans.get("sequence")
|
| 14 |
+
if not isinstance(x, list) or not (1 <= len(x) <= inst["max_length"]):
|
| 15 |
+
raise Invalid(f"sequence must be a list of 1..{inst['max_length']} entries")
|
| 16 |
+
int_list(x, None, -1, 1, "sequence")
|
| 17 |
+
if 0 in x:
|
| 18 |
+
raise Invalid("entries must be +1 or -1")
|
| 19 |
+
a = np.array(x, dtype=np.int64)
|
| 20 |
+
n, c = len(x), inst["C"]
|
| 21 |
+
for d in range(1, n // (c + 1) + 1): # progressions with fewer than c+1 terms cannot exceed c
|
| 22 |
+
ps = np.cumsum(a[d - 1::d])
|
| 23 |
+
m = int(np.abs(ps).max())
|
| 24 |
+
if m > c:
|
| 25 |
+
k = int(np.argmax(np.abs(ps) > c)) + 1
|
| 26 |
+
raise Invalid(f"|x_{d} + x_{2 * d} + ... + x_{k * d}| = {abs(int(ps[k - 1]))} > {c}")
|
| 27 |
+
return float(n), {"length": n}
|
graders/ae_p56_szemeredi_trotter/check.py
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Point-line incidences (AlphaEvolve problem 56, Szemeredi-Trotter constructions), integer version.
|
| 2 |
+
|
| 3 |
+
n distinct lattice points (x, y) and m distinct lines a x + b y = c with integer a, b, c ((a, b) != (0, 0));
|
| 4 |
+
lines are compared after dividing by gcd(a, b, c) and fixing the sign, so duplicates in disguise are caught.
|
| 5 |
+
Score = number of pairs (point, line) with a x + b y = c, counted exactly in int64 (all bounds below keep
|
| 6 |
+
|a x + b y - c| < 2^62). Upstream (szemeredi_trotter_constructions.ipynb) silently dropped duplicate lines and
|
| 7 |
+
padded the point set from a grid height H; here both sets are explicit and duplicates are rejected.
|
| 8 |
+
"""
|
| 9 |
+
import math
|
| 10 |
+
|
| 11 |
+
import numpy as np
|
| 12 |
+
|
| 13 |
+
from run import Invalid, int_list
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def check(inst, ans):
|
| 17 |
+
n, m, R, RC = inst["n"], inst["m"], inst["max_coord"], inst["max_coef"]
|
| 18 |
+
pts, lines = ans.get("points"), ans.get("lines")
|
| 19 |
+
if not isinstance(pts, list) or len(pts) != n:
|
| 20 |
+
raise Invalid(f"points must be a list of exactly {n} pairs")
|
| 21 |
+
if not isinstance(lines, list) or len(lines) != m:
|
| 22 |
+
raise Invalid(f"lines must be a list of exactly {m} triples")
|
| 23 |
+
P = np.array([int_list(p, 2, -R, R, "point") for p in pts], dtype=np.int64)
|
| 24 |
+
if len({(int(x), int(y)) for x, y in P}) != n:
|
| 25 |
+
raise Invalid("points must be distinct")
|
| 26 |
+
norm = set()
|
| 27 |
+
for ln in lines:
|
| 28 |
+
a, b, c = int_list(ln, 3, None, None, "line")
|
| 29 |
+
if max(abs(a), abs(b)) > RC or abs(c) > RC * R * 2:
|
| 30 |
+
raise Invalid(f"line coefficients out of range: |a|, |b| <= {RC}, |c| <= {2 * RC * R}")
|
| 31 |
+
if a == 0 and b == 0:
|
| 32 |
+
raise Invalid("a and b cannot both be zero")
|
| 33 |
+
g = math.gcd(math.gcd(a, b), c)
|
| 34 |
+
a, b, c = a // g, b // g, c // g
|
| 35 |
+
if a < 0 or (a == 0 and b < 0):
|
| 36 |
+
a, b, c = -a, -b, -c
|
| 37 |
+
norm.add((a, b, c))
|
| 38 |
+
if len(norm) != m:
|
| 39 |
+
raise Invalid("lines must be distinct")
|
| 40 |
+
L = np.array(sorted(norm), dtype=np.int64)
|
| 41 |
+
inc = 0
|
| 42 |
+
for s in range(0, m, 256):
|
| 43 |
+
blk = L[s:s + 256]
|
| 44 |
+
inc += int(np.count_nonzero(blk[:, 0:1] * P[None, :, 0] + blk[:, 1:2] * P[None, :, 1] == blk[:, 2:3]))
|
| 45 |
+
return float(inc), {"incidences": inc}
|
graders/ae_p57_rudin_l4/check.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Rudin-type flatness of spherical harmonics on S^2 (AlphaEvolve problem 57, p = 4): minimize ||u||_4 / ||u||_2.
|
| 2 |
+
|
| 3 |
+
u = sum_{m=-D..D} c_m Y_D^m with the real orthonormal basis (normalized surface measure, total mass 1)
|
| 4 |
+
Y_D^0 = N_{D,0} P_D(cos t), Y_D^m = sqrt(2) N_{D,m} P_D^m(cos t) cos(m f), Y_D^-m = sqrt(2) N_{D,m} P_D^m(cos t) sin(m f),
|
| 5 |
+
P_D^m(x) = (1 - x^2)^{m/2} d^m/dx^m P_D(x) (no Condon-Shortley phase), N_{D,m} = sqrt((2D+1)(D-m)!/(D+m)!).
|
| 6 |
+
Then ||u||_2^2 = sum c_m^2, and ||u||_4^4 = int u^4 dsigma is integrated EXACTLY (up to float64 rounding) by a
|
| 7 |
+
product rule: (2D+1)-point Gauss-Legendre in cos t (exact for polynomials of degree <= 4D+1) times 4D+1 equally
|
| 8 |
+
spaced azimuths (exact for trigonometric polynomials of degree <= 4D); u^4 is in that class.
|
| 9 |
+
Upstream (rudin_problem.ipynb) evaluated the same ratio through Gaunt coefficients with np.isclose()-based
|
| 10 |
+
pruning of "small" coefficients (|c| < 1e-8 silently dropped); the exact quadrature replaces it.
|
| 11 |
+
"""
|
| 12 |
+
import math
|
| 13 |
+
|
| 14 |
+
import numpy as np
|
| 15 |
+
from scipy.special import lpmv
|
| 16 |
+
|
| 17 |
+
from run import Invalid, float_list
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def basis(D):
|
| 21 |
+
t, w = np.polynomial.legendre.leggauss(2 * D + 1)
|
| 22 |
+
M = 4 * D + 1
|
| 23 |
+
phi = 2 * np.pi * np.arange(M) / M
|
| 24 |
+
rows = []
|
| 25 |
+
for m in range(-D, D + 1):
|
| 26 |
+
a = abs(m)
|
| 27 |
+
nrm = math.sqrt((2 * D + 1) * math.exp(math.lgamma(D - a + 1) - math.lgamma(D + a + 1)))
|
| 28 |
+
P = (-1) ** a * lpmv(a, D, t) * nrm
|
| 29 |
+
ang = math.sqrt(2) * (np.cos(a * phi) if m > 0 else np.sin(a * phi)) if m else np.ones(M)
|
| 30 |
+
rows.append(np.outer(P, ang).ravel())
|
| 31 |
+
return np.array(rows), np.outer(w / 2, np.full(M, 1.0 / M)).ravel()
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
def check(inst, ans):
|
| 35 |
+
D = inst["D"]
|
| 36 |
+
c = np.array(float_list(ans.get("coeffs"), 2 * D + 1, "coeffs"))
|
| 37 |
+
a = np.abs(c).max()
|
| 38 |
+
if a > 1e6:
|
| 39 |
+
raise Invalid("coefficients must lie in [-1e6, 1e6]")
|
| 40 |
+
if a < 1e-6:
|
| 41 |
+
raise Invalid("u must not be (nearly) zero: need max |c_m| >= 1e-6")
|
| 42 |
+
c = c / a
|
| 43 |
+
Y, W = basis(D)
|
| 44 |
+
u = c @ Y
|
| 45 |
+
r = float(np.sum(W * u ** 4)) ** 0.25 / math.sqrt(float(c @ c))
|
| 46 |
+
return r, {"l4_over_l2": r}
|
graders/ale_ahc002/check.py
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""ALE-Bench ahc002 (AtCoder Heuristic Contest 002 "Walking on Tiles"): Python port of the official
|
| 2 |
+
tools/src/lib.rs (read_input / read_output / compute_score_detail). Answer = the contestant's stdout text.
|
| 3 |
+
Score = sum of p over visited squares (incl. start); any rule violation = WA -> Invalid."""
|
| 4 |
+
from run import Invalid
|
| 5 |
+
|
| 6 |
+
N = 50
|
| 7 |
+
MAX_LEN = 100_000
|
| 8 |
+
# Rust str::trim() strips Unicode White_Space (Python's str.strip also strips \x1c-\x1f, so do it by hand)
|
| 9 |
+
_WS = set("\t\n\x0b\x0c\r \x85\xa0 "
|
| 10 |
+
"
")
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def rust_trim(s):
|
| 14 |
+
a, b = 0, len(s)
|
| 15 |
+
while a < b and s[a] in _WS:
|
| 16 |
+
a += 1
|
| 17 |
+
while b > a and s[b - 1] in _WS:
|
| 18 |
+
b -= 1
|
| 19 |
+
return s[a:b]
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def parse_input(text):
|
| 23 |
+
t = [int(x) for x in text.split()]
|
| 24 |
+
si, sj = t[0], t[1]
|
| 25 |
+
tiles = [t[2 + i * N: 2 + (i + 1) * N] for i in range(N)]
|
| 26 |
+
o = 2 + N * N
|
| 27 |
+
ps = [t[o + i * N: o + (i + 1) * N] for i in range(N)]
|
| 28 |
+
return (si, sj), tiles, ps
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def check(inst, ans):
|
| 32 |
+
out = ans.get("output")
|
| 33 |
+
if not isinstance(out, str):
|
| 34 |
+
raise Invalid("output must be a string")
|
| 35 |
+
if len(out) > MAX_LEN:
|
| 36 |
+
raise Invalid(f"output longer than {MAX_LEN} characters")
|
| 37 |
+
if not out.isascii():
|
| 38 |
+
raise Invalid("output must be ASCII")
|
| 39 |
+
(i, j), tiles, ps = parse_input(inst["input"])
|
| 40 |
+
out = rust_trim(out)
|
| 41 |
+
used = set([tiles[i][j]])
|
| 42 |
+
score = ps[i][j]
|
| 43 |
+
D = {"L": (0, -1), "R": (0, 1), "U": (-1, 0), "D": (1, 0)}
|
| 44 |
+
for c in out:
|
| 45 |
+
if c not in D:
|
| 46 |
+
raise Invalid("Illegal output")
|
| 47 |
+
di, dj = D[c]
|
| 48 |
+
i += di
|
| 49 |
+
j += dj
|
| 50 |
+
if not (0 <= i < N and 0 <= j < N):
|
| 51 |
+
raise Invalid("Out of range")
|
| 52 |
+
tl = tiles[i][j]
|
| 53 |
+
if tl in used:
|
| 54 |
+
raise Invalid("Stepped on the same tile twice")
|
| 55 |
+
used.add(tl)
|
| 56 |
+
score += ps[i][j]
|
| 57 |
+
return float(score), {"moves": len(out)}
|
graders/ale_ahc004/check.py
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""ALE-Bench ahc004 (AHC 004 "Alien's Genome Assembly"): Python port of the official tools/src/lib.rs
|
| 2 |
+
(parse_output + compute_score_detail). Answer = the contestant's stdout text (N lines of length N)."""
|
| 3 |
+
import math
|
| 4 |
+
import re
|
| 5 |
+
|
| 6 |
+
from run import Invalid
|
| 7 |
+
|
| 8 |
+
N = 20
|
| 9 |
+
MAX_LEN = 100_000
|
| 10 |
+
# Rust split_whitespace() splits on Unicode White_Space (Python's str.split also splits on \x1c-\x1f)
|
| 11 |
+
_WS_RE = re.compile("[\t\n\x0b\x0c\r \x85\xa0 -
]+")
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
def rust_split_ws(s):
|
| 15 |
+
return [t for t in _WS_RE.split(s) if t]
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def rust_round(x): # f64::round (half away from zero), x >= 0
|
| 19 |
+
r = math.floor(x)
|
| 20 |
+
return r + 1 if x - r >= 0.5 else r
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def check(inst, ans):
|
| 24 |
+
out = ans.get("output")
|
| 25 |
+
if not isinstance(out, str):
|
| 26 |
+
raise Invalid("output must be a string")
|
| 27 |
+
if len(out) > MAX_LEN:
|
| 28 |
+
raise Invalid(f"output longer than {MAX_LEN} characters")
|
| 29 |
+
if not out.isascii():
|
| 30 |
+
raise Invalid("output must be ASCII")
|
| 31 |
+
tok = inst["input"].split()
|
| 32 |
+
M = int(tok[1])
|
| 33 |
+
S = tok[2:2 + M]
|
| 34 |
+
rows = rust_split_ws(out)
|
| 35 |
+
if len(rows) < N:
|
| 36 |
+
raise Invalid("Unexpected EOF")
|
| 37 |
+
if len(rows) > N:
|
| 38 |
+
raise Invalid("Too many lines")
|
| 39 |
+
d = 0
|
| 40 |
+
for r in rows:
|
| 41 |
+
if len(r) != N:
|
| 42 |
+
raise Invalid(f"illegal length: {len(r)}")
|
| 43 |
+
for ch in r:
|
| 44 |
+
if not ("A" <= ch <= "H") and ch != ".":
|
| 45 |
+
raise Invalid(f"illegal char: {ch}")
|
| 46 |
+
if ch == ".":
|
| 47 |
+
d += 1
|
| 48 |
+
present = set()
|
| 49 |
+
for i in range(N):
|
| 50 |
+
for j in range(N):
|
| 51 |
+
for di, dj in ((0, 1), (1, 0)):
|
| 52 |
+
s = []
|
| 53 |
+
for k in range(12):
|
| 54 |
+
s.append(rows[(i + di * k) % N][(j + dj * k) % N])
|
| 55 |
+
present.add("".join(s))
|
| 56 |
+
c = sum(1 for s in S if s in present)
|
| 57 |
+
if c < M:
|
| 58 |
+
score = rust_round(1e8 * c / M)
|
| 59 |
+
else:
|
| 60 |
+
score = rust_round(1e8 * (2 * N * N) / (2 * N * N - d))
|
| 61 |
+
return float(score), {"c": c, "M": M, "dots": d}
|
graders/ale_ahc009/check.py
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""ALE-Bench ahc009 (AHC 009 "Robust Memory of Commuting Routes"): Python port of the official
|
| 2 |
+
tools/src/lib.rs (parse_output + compute_score), replicating the f64 operation order exactly.
|
| 3 |
+
Answer = the contestant's stdout text (a U/D/L/R string of length <= 200)."""
|
| 4 |
+
import math
|
| 5 |
+
|
| 6 |
+
from run import Invalid
|
| 7 |
+
|
| 8 |
+
N = 20
|
| 9 |
+
L = 200
|
| 10 |
+
DIJ = [(-1, 0), (0, -1), (1, 0), (0, 1)]
|
| 11 |
+
DIR = "ULDR"
|
| 12 |
+
_WS = set("\t\n\x0b\x0c\r \x85\xa0 "
|
| 13 |
+
"
")
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def rust_trim(s):
|
| 17 |
+
a, b = 0, len(s)
|
| 18 |
+
while a < b and s[a] in _WS:
|
| 19 |
+
a += 1
|
| 20 |
+
while b > a and s[b - 1] in _WS:
|
| 21 |
+
b -= 1
|
| 22 |
+
return s[a:b]
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def rust_round(x): # f64::round, half away from zero
|
| 26 |
+
r = math.floor(abs(x))
|
| 27 |
+
r = r + 1 if abs(x) - r >= 0.5 else r
|
| 28 |
+
return r if x >= 0 else -r
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def check(inst, ans):
|
| 32 |
+
out = ans.get("output")
|
| 33 |
+
if not isinstance(out, str):
|
| 34 |
+
raise Invalid("output must be a string")
|
| 35 |
+
if len(out) > 10_000:
|
| 36 |
+
raise Invalid("too long output")
|
| 37 |
+
if not out.isascii():
|
| 38 |
+
raise Invalid("output must be ASCII")
|
| 39 |
+
tok = inst["input"].split()
|
| 40 |
+
si, sj, ti, tj = (int(x) for x in tok[:4])
|
| 41 |
+
p = float(tok[4])
|
| 42 |
+
hs = [[c == "1" for c in tok[5 + i]] for i in range(N)]
|
| 43 |
+
vs = [[c == "1" for c in tok[5 + N + i]] for i in range(N - 1)]
|
| 44 |
+
|
| 45 |
+
def can_move(i, j, d):
|
| 46 |
+
if d == 0:
|
| 47 |
+
return i > 0 and not vs[i - 1][j]
|
| 48 |
+
if d == 1:
|
| 49 |
+
return j > 0 and not hs[i][j - 1]
|
| 50 |
+
if d == 2:
|
| 51 |
+
return i < N - 1 and not vs[i][j]
|
| 52 |
+
return j < N - 1 and not hs[i][j]
|
| 53 |
+
|
| 54 |
+
out = rust_trim(out)
|
| 55 |
+
crt = [[0.0] * N for _ in range(N)]
|
| 56 |
+
crt[si][sj] = 1.0
|
| 57 |
+
s = 0.0
|
| 58 |
+
goal = 0.0
|
| 59 |
+
q = 1.0 - p
|
| 60 |
+
for t, ch in enumerate(out):
|
| 61 |
+
if t >= L:
|
| 62 |
+
raise Invalid("too long output")
|
| 63 |
+
d = DIR.find(ch)
|
| 64 |
+
if d < 0:
|
| 65 |
+
raise Invalid(f"illegal char: {ch}")
|
| 66 |
+
nxt = [[0.0] * N for _ in range(N)]
|
| 67 |
+
di, dj = DIJ[d]
|
| 68 |
+
for i in range(N):
|
| 69 |
+
row = crt[i]
|
| 70 |
+
for j in range(N):
|
| 71 |
+
c = row[j]
|
| 72 |
+
if c > 0.0:
|
| 73 |
+
if can_move(i, j, d):
|
| 74 |
+
nxt[i + di][j + dj] += c * q
|
| 75 |
+
nxt[i][j] += c * p
|
| 76 |
+
else:
|
| 77 |
+
nxt[i][j] += c
|
| 78 |
+
crt = nxt
|
| 79 |
+
s += crt[ti][tj] * (2 * L - t)
|
| 80 |
+
goal += crt[ti][tj]
|
| 81 |
+
crt[ti][tj] = 0.0
|
| 82 |
+
return float(rust_round(1e8 * s / (2 * L))), {"length": len(out), "p_reach": goal}
|
graders/ale_ahc010/check.py
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""ALE-Bench ahc010 (AHC 010 "Loop Lines"): Python port of the official tools/src/lib.rs (parse_output +
|
| 2 |
+
compute_score; the tester scores the LAST output line). Answer = the contestant's stdout text."""
|
| 3 |
+
from run import Invalid
|
| 4 |
+
|
| 5 |
+
N = 30
|
| 6 |
+
MAX_LEN = 200_000
|
| 7 |
+
ROTATE = [1, 2, 3, 0, 5, 4, 7, 6]
|
| 8 |
+
X = -1
|
| 9 |
+
TO = [[1, 0, X, X], [3, X, X, 0], [X, X, 3, 2], [X, 2, 1, X], [1, 0, 3, 2], [3, 2, 1, 0], [2, X, 0, X], [X, 3, X, 1]]
|
| 10 |
+
DIJ = [(0, -1), (-1, 0), (0, 1), (1, 0)]
|
| 11 |
+
_WS = set("\t\n\x0b\x0c\r ") # output is required to be ASCII, so Rust's trim() reduces to these
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
def rust_lines(s):
|
| 15 |
+
parts = s.split("\n")
|
| 16 |
+
if parts and parts[-1] == "":
|
| 17 |
+
parts.pop()
|
| 18 |
+
return [p[:-1] if p.endswith("\r") else p for p in parts]
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def rust_trim(s):
|
| 22 |
+
a, b = 0, len(s)
|
| 23 |
+
while a < b and s[a] in _WS:
|
| 24 |
+
a += 1
|
| 25 |
+
while b > a and s[b - 1] in _WS:
|
| 26 |
+
b -= 1
|
| 27 |
+
return s[a:b]
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
def check(inst, ans):
|
| 31 |
+
out = ans.get("output")
|
| 32 |
+
if not isinstance(out, str):
|
| 33 |
+
raise Invalid("output must be a string")
|
| 34 |
+
if len(out) > MAX_LEN:
|
| 35 |
+
raise Invalid(f"output longer than {MAX_LEN} characters")
|
| 36 |
+
if not out.isascii():
|
| 37 |
+
raise Invalid("output must be ASCII")
|
| 38 |
+
rows = inst["input"].split()
|
| 39 |
+
tiles0 = [[ord(c) - 48 for c in rows[i]] for i in range(N)]
|
| 40 |
+
outs = []
|
| 41 |
+
for line in rust_lines(out):
|
| 42 |
+
line = rust_trim(line)
|
| 43 |
+
tmp = []
|
| 44 |
+
for c in line:
|
| 45 |
+
if c < "0" or "3" < c:
|
| 46 |
+
raise Invalid(f"Illegal output: {c}")
|
| 47 |
+
tmp.append(ord(c) - 48)
|
| 48 |
+
if len(tmp) != N * N:
|
| 49 |
+
raise Invalid(f"Illegal output length: {len(line)}")
|
| 50 |
+
outs.append(tmp)
|
| 51 |
+
if not outs:
|
| 52 |
+
raise Invalid("empty output")
|
| 53 |
+
r = outs[-1]
|
| 54 |
+
tiles = [row[:] for row in tiles0]
|
| 55 |
+
for i in range(N):
|
| 56 |
+
for j in range(N):
|
| 57 |
+
for _ in range(r[i * N + j]):
|
| 58 |
+
tiles[i][j] = ROTATE[tiles[i][j]]
|
| 59 |
+
used = [[[False] * 4 for _ in range(N)] for _ in range(N)]
|
| 60 |
+
ls = []
|
| 61 |
+
for i in range(N):
|
| 62 |
+
for j in range(N):
|
| 63 |
+
for d in range(4):
|
| 64 |
+
if TO[tiles[i][j]][d] != X and not used[i][j][d]:
|
| 65 |
+
i2, j2, d2 = i, j, d
|
| 66 |
+
length = 0
|
| 67 |
+
while not used[i2][j2][d2]:
|
| 68 |
+
if TO[tiles[i2][j2]][d2] == X:
|
| 69 |
+
break
|
| 70 |
+
length += 1
|
| 71 |
+
used[i2][j2][d2] = True
|
| 72 |
+
d2 = TO[tiles[i2][j2]][d2]
|
| 73 |
+
used[i2][j2][d2] = True
|
| 74 |
+
i2 += DIJ[d2][0]
|
| 75 |
+
j2 += DIJ[d2][1]
|
| 76 |
+
if not (0 <= i2 < N and 0 <= j2 < N):
|
| 77 |
+
break
|
| 78 |
+
d2 = (d2 + 2) % 4
|
| 79 |
+
if (i, j, d) == (i2, j2, d2):
|
| 80 |
+
ls.append(length)
|
| 81 |
+
if len(ls) <= 1:
|
| 82 |
+
score = 0
|
| 83 |
+
else:
|
| 84 |
+
ls.sort()
|
| 85 |
+
score = ls[-1] * ls[-2]
|
| 86 |
+
return float(score), {"loops": len(ls), "L1": ls[-1] if ls else 0, "L2": ls[-2] if len(ls) > 1 else 0}
|
graders/ale_ahc011/check.py
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""ALE-Bench ahc011 (AHC 011 "Sliding Tree Puzzle"): Python port of the official tools/src/lib.rs
|
| 2 |
+
(parse_output, Sim::apply, Sim::compute_score). Answer = the contestant's stdout text (a L/U/R/D string)."""
|
| 3 |
+
import math
|
| 4 |
+
|
| 5 |
+
from run import Invalid
|
| 6 |
+
|
| 7 |
+
DIJ = [(0, -1), (-1, 0), (0, 1), (1, 0)]
|
| 8 |
+
DIR = "LURD"
|
| 9 |
+
_WS = set("\t\n\x0b\x0c\r ") # output must be ASCII; Rust trim() then strips exactly these
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
def rust_trim(s):
|
| 13 |
+
a, b = 0, len(s)
|
| 14 |
+
while a < b and s[a] in _WS:
|
| 15 |
+
a += 1
|
| 16 |
+
while b > a and s[b - 1] in _WS:
|
| 17 |
+
b -= 1
|
| 18 |
+
return s[a:b]
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def rust_round(x): # f64::round for x >= 0
|
| 22 |
+
r = math.floor(x)
|
| 23 |
+
return r + 1 if x - r >= 0.5 else r
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def check(inst, ans):
|
| 27 |
+
out = ans.get("output")
|
| 28 |
+
if not isinstance(out, str):
|
| 29 |
+
raise Invalid("output must be a string")
|
| 30 |
+
tok = inst["input"].split()
|
| 31 |
+
n, T = int(tok[0]), int(tok[1])
|
| 32 |
+
if len(out) > 4 * T + 1000:
|
| 33 |
+
raise Invalid("output too long")
|
| 34 |
+
if not out.isascii():
|
| 35 |
+
raise Invalid("output must be ASCII")
|
| 36 |
+
tiles0 = [[int(c, 16) for c in tok[2 + i]] for i in range(n)]
|
| 37 |
+
ei = ej = None
|
| 38 |
+
for x in range(n):
|
| 39 |
+
for y in range(n):
|
| 40 |
+
if tiles0[x][y] == 0:
|
| 41 |
+
ei, ej = x, y
|
| 42 |
+
frm = [[(x, y) for y in range(n)] for x in range(n)]
|
| 43 |
+
turn = 0
|
| 44 |
+
for c in rust_trim(out):
|
| 45 |
+
d = DIR.find(c)
|
| 46 |
+
if d < 0:
|
| 47 |
+
raise Invalid(f"illegal move: {c} (turn {turn})")
|
| 48 |
+
i2, j2 = ei + DIJ[d][0], ej + DIJ[d][1]
|
| 49 |
+
if not (0 <= i2 < n and 0 <= j2 < n):
|
| 50 |
+
raise Invalid(f"illegal move: {c} (turn {turn})")
|
| 51 |
+
frm[i2][j2], frm[ei][ej] = frm[ei][ej], frm[i2][j2]
|
| 52 |
+
ei, ej = i2, j2
|
| 53 |
+
turn += 1
|
| 54 |
+
tiles = [[tiles0[frm[i][j][0]][frm[i][j][1]] for j in range(n)] for i in range(n)]
|
| 55 |
+
par = list(range(n * n))
|
| 56 |
+
size = [1] * (n * n)
|
| 57 |
+
tree = [True] * (n * n)
|
| 58 |
+
|
| 59 |
+
def find(x):
|
| 60 |
+
while par[x] != x:
|
| 61 |
+
par[x] = par[par[x]]
|
| 62 |
+
x = par[x]
|
| 63 |
+
return x
|
| 64 |
+
|
| 65 |
+
def join(a, b):
|
| 66 |
+
a, b = find(a), find(b)
|
| 67 |
+
if a == b:
|
| 68 |
+
tree[a] = False
|
| 69 |
+
return
|
| 70 |
+
t = tree[a] and tree[b]
|
| 71 |
+
if size[a] < size[b]:
|
| 72 |
+
a, b = b, a
|
| 73 |
+
par[b] = a
|
| 74 |
+
size[a] += size[b]
|
| 75 |
+
tree[a] = t
|
| 76 |
+
|
| 77 |
+
for i in range(n):
|
| 78 |
+
for j in range(n):
|
| 79 |
+
if i + 1 < n and tiles[i][j] & 8 and tiles[i + 1][j] & 2:
|
| 80 |
+
join(i * n + j, (i + 1) * n + j)
|
| 81 |
+
if j + 1 < n and tiles[i][j] & 4 and tiles[i][j + 1] & 1:
|
| 82 |
+
join(i * n + j, i * n + j + 1)
|
| 83 |
+
best = 0
|
| 84 |
+
for i in range(n):
|
| 85 |
+
for j in range(n):
|
| 86 |
+
if tiles[i][j] != 0:
|
| 87 |
+
r = find(i * n + j)
|
| 88 |
+
if tree[r]:
|
| 89 |
+
best = max(best, size[r])
|
| 90 |
+
if turn > T:
|
| 91 |
+
raise Invalid("too many moves")
|
| 92 |
+
if best == n * n - 1:
|
| 93 |
+
score = rust_round(500000.0 * (1.0 + (T - turn) / T))
|
| 94 |
+
else:
|
| 95 |
+
score = rust_round(500000.0 * best / (n * n - 1))
|
| 96 |
+
return float(score), {"K": turn, "S": best, "N": n}
|
graders/ale_ahc014/check.py
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""ALE-Bench ahc014 (AHC 014 "RectJoin"): Python port of the official tools/src/lib.rs (parse_output,
|
| 2 |
+
State::check_move / apply_move, compute_score). Answer = the contestant's stdout text."""
|
| 3 |
+
import math
|
| 4 |
+
import re
|
| 5 |
+
|
| 6 |
+
from run import Invalid
|
| 7 |
+
|
| 8 |
+
DXY = [(1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)]
|
| 9 |
+
DIRI = {v: k for k, v in enumerate(DXY)}
|
| 10 |
+
_INT = re.compile(r"[+-]?[0-9]+\Z")
|
| 11 |
+
_WS = re.compile(r"[\t\n\x0b\x0c\r ]+") # output must be ASCII; Rust split_whitespace on ASCII = these
|
| 12 |
+
MAX_LEN = 2_000_000
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def rust_round(x):
|
| 16 |
+
r = math.floor(x)
|
| 17 |
+
return r + 1 if x - r >= 0.5 else r
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def read(tokens, pos, lb, ub):
|
| 21 |
+
if pos >= len(tokens):
|
| 22 |
+
raise Invalid("Unexpected EOF")
|
| 23 |
+
t = tokens[pos]
|
| 24 |
+
if not _INT.match(t):
|
| 25 |
+
raise Invalid(f"Parse error: {t[:20]}")
|
| 26 |
+
v = int(t)
|
| 27 |
+
if not (-2 ** 31 <= v < 2 ** 31):
|
| 28 |
+
raise Invalid(f"Parse error: {t[:20]}")
|
| 29 |
+
if v < lb or ub < v:
|
| 30 |
+
raise Invalid(f"Out of range: {v}")
|
| 31 |
+
return v
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
def weight(p, N):
|
| 35 |
+
dx = p[0] - N // 2
|
| 36 |
+
dy = p[1] - N // 2
|
| 37 |
+
return dx * dx + dy * dy + 1
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
def sgn(v):
|
| 41 |
+
return (v > 0) - (v < 0)
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
def check(inst, ans):
|
| 45 |
+
out = ans.get("output")
|
| 46 |
+
if not isinstance(out, str):
|
| 47 |
+
raise Invalid("output must be a string")
|
| 48 |
+
if len(out) > MAX_LEN:
|
| 49 |
+
raise Invalid(f"output longer than {MAX_LEN} characters")
|
| 50 |
+
if not out.isascii():
|
| 51 |
+
raise Invalid("output must be ASCII")
|
| 52 |
+
tok = inst["input"].split()
|
| 53 |
+
N, M = int(tok[0]), int(tok[1])
|
| 54 |
+
ps = [(int(tok[2 + 2 * i]), int(tok[3 + 2 * i])) for i in range(M)]
|
| 55 |
+
tokens = [t for t in _WS.split(out) if t]
|
| 56 |
+
K = read(tokens, 0, 0, 1000000000)
|
| 57 |
+
if K == 0:
|
| 58 |
+
raise Invalid("K = 0 is not accepted in this conversion (perform at least one operation)")
|
| 59 |
+
pos = 1
|
| 60 |
+
rects = []
|
| 61 |
+
for _ in range(K):
|
| 62 |
+
r = []
|
| 63 |
+
for i in range(4):
|
| 64 |
+
x = read(tokens, pos, 0, N - 1)
|
| 65 |
+
y = read(tokens, pos + 1, 0, N - 1)
|
| 66 |
+
pos += 2
|
| 67 |
+
r.append((x, y))
|
| 68 |
+
rects.append(r)
|
| 69 |
+
has = [[False] * N for _ in range(N)]
|
| 70 |
+
used = [[[False] * 8 for _ in range(N)] for _ in range(N)]
|
| 71 |
+
for (x, y) in ps:
|
| 72 |
+
has[x][y] = True
|
| 73 |
+
for t, rect in enumerate(rects):
|
| 74 |
+
err = None
|
| 75 |
+
bad = [i for i in (1, 2, 3) if not has[rect[i][0]][rect[i][1]]]
|
| 76 |
+
if bad:
|
| 77 |
+
err = f"{rect[bad[0]]} does not contain a dot"
|
| 78 |
+
elif has[rect[0][0]][rect[0][1]]:
|
| 79 |
+
err = f"{rect[0]} already contains a dot"
|
| 80 |
+
else:
|
| 81 |
+
dx01 = rect[1][0] - rect[0][0]
|
| 82 |
+
dy01 = rect[1][1] - rect[0][1]
|
| 83 |
+
dx03 = rect[3][0] - rect[0][0]
|
| 84 |
+
dy03 = rect[3][1] - rect[0][1]
|
| 85 |
+
if dx01 * dx03 + dy01 * dy03 != 0:
|
| 86 |
+
err = "Illegal rectangle"
|
| 87 |
+
elif dx01 != 0 and dy01 != 0 and abs(dx01) != abs(dy01):
|
| 88 |
+
err = "Illegal rectangle"
|
| 89 |
+
elif (rect[1][0] + dx03, rect[1][1] + dy03) != rect[2]:
|
| 90 |
+
err = "Illegal rectangle"
|
| 91 |
+
else:
|
| 92 |
+
for i in range(4):
|
| 93 |
+
x, y = rect[i]
|
| 94 |
+
tx, ty = rect[(i + 1) % 4]
|
| 95 |
+
dx, dy = sgn(tx - x), sgn(ty - y)
|
| 96 |
+
d = DIRI[(dx, dy)]
|
| 97 |
+
while (x, y) != (tx, ty):
|
| 98 |
+
if (x, y) != rect[i] and has[x][y]:
|
| 99 |
+
err = f"There is an obstacle at ({x}, {y})"
|
| 100 |
+
break
|
| 101 |
+
if used[x][y][d]:
|
| 102 |
+
err = "Overlapped rectangles"
|
| 103 |
+
break
|
| 104 |
+
x += dx
|
| 105 |
+
y += dy
|
| 106 |
+
if used[x][y][d ^ 4]:
|
| 107 |
+
err = "Overlapped rectangles"
|
| 108 |
+
break
|
| 109 |
+
if err:
|
| 110 |
+
break
|
| 111 |
+
if err:
|
| 112 |
+
raise Invalid(f"{err} (turn: {t})")
|
| 113 |
+
has[rect[0][0]][rect[0][1]] = True
|
| 114 |
+
for i in range(4):
|
| 115 |
+
x, y = rect[i]
|
| 116 |
+
tx, ty = rect[(i + 1) % 4]
|
| 117 |
+
dx, dy = sgn(tx - x), sgn(ty - y)
|
| 118 |
+
d = DIRI[(dx, dy)]
|
| 119 |
+
while (x, y) != (tx, ty):
|
| 120 |
+
used[x][y][d] = True
|
| 121 |
+
x += dx
|
| 122 |
+
y += dy
|
| 123 |
+
used[x][y][d ^ 4] = True
|
| 124 |
+
num = sum(weight(p, N) for p in ps) + sum(weight(r[0], N) for r in rects)
|
| 125 |
+
den = sum(weight((i, j), N) for i in range(N) for j in range(N))
|
| 126 |
+
score = rust_round(1e6 * (N * N) / M * num / den)
|
| 127 |
+
return float(score), {"K": K}
|
graders/ale_ahc017/check.py
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""ALE-Bench ahc017 (AHC 017 "Road Repair"): Python port of the official tools/src/lib.rs (parse_output +
|
| 2 |
+
compute_score). All-pairs shortest paths per day via scipy's Dijkstra (float64 holds the integer path lengths,
|
| 3 |
+
all <= 1e9 < 2^53, exactly); unreachable pairs count as 1e9 as in the tool. The final division replicates
|
| 4 |
+
Rust's `num as f64 / den as f64 * 1000.0` and f64::round. Answer = the contestant's stdout text."""
|
| 5 |
+
import math
|
| 6 |
+
import re
|
| 7 |
+
|
| 8 |
+
import numpy as np
|
| 9 |
+
from scipy.sparse import csr_matrix
|
| 10 |
+
from scipy.sparse.csgraph import dijkstra
|
| 11 |
+
|
| 12 |
+
from run import Invalid
|
| 13 |
+
|
| 14 |
+
INF = 1_000_000_000
|
| 15 |
+
_UINT = re.compile(r"\+?[0-9]+\Z") # Rust usize::from_str: optional '+', ASCII digits
|
| 16 |
+
_WS = re.compile(r"[\t\n\x0b\x0c\r ]+")
|
| 17 |
+
MAX_LEN = 200_000
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def rust_round(x):
|
| 21 |
+
r = math.floor(x)
|
| 22 |
+
return r + 1 if x - r >= 0.5 else r
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def parse_input(text):
|
| 26 |
+
t = [int(x) for x in text.split()]
|
| 27 |
+
N, M, D, K = t[:4]
|
| 28 |
+
es = [(t[4 + 3 * i] - 1, t[5 + 3 * i] - 1, t[6 + 3 * i]) for i in range(M)]
|
| 29 |
+
return N, M, D, K, es
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def apsp(N, es, mask):
|
| 33 |
+
best = {}
|
| 34 |
+
for (u, v, w), keep in zip(es, mask):
|
| 35 |
+
if keep:
|
| 36 |
+
a, b = (u, v) if u < v else (v, u)
|
| 37 |
+
if (a, b) not in best or w < best[(a, b)]:
|
| 38 |
+
best[(a, b)] = w
|
| 39 |
+
if best:
|
| 40 |
+
rows, cols, ws = zip(*[(a, b, w) for (a, b), w in best.items()])
|
| 41 |
+
else:
|
| 42 |
+
rows, cols, ws = (), (), ()
|
| 43 |
+
g = csr_matrix((np.array(ws, dtype=np.float64), (np.array(rows, dtype=np.int64), np.array(cols, dtype=np.int64))),
|
| 44 |
+
shape=(N, N))
|
| 45 |
+
d = dijkstra(g, directed=False)
|
| 46 |
+
d[~np.isfinite(d)] = INF
|
| 47 |
+
return d.astype(np.int64)
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
def check(inst, ans):
|
| 51 |
+
out = ans.get("output")
|
| 52 |
+
if not isinstance(out, str):
|
| 53 |
+
raise Invalid("output must be a string")
|
| 54 |
+
if len(out) > MAX_LEN:
|
| 55 |
+
raise Invalid(f"output longer than {MAX_LEN} characters")
|
| 56 |
+
if not out.isascii():
|
| 57 |
+
raise Invalid("output must be ASCII")
|
| 58 |
+
N, M, D, K, es = parse_input(inst["input"])
|
| 59 |
+
tokens = [t for t in _WS.split(out) if t]
|
| 60 |
+
r = []
|
| 61 |
+
for k in range(M):
|
| 62 |
+
if k >= len(tokens):
|
| 63 |
+
raise Invalid("Unexpected EOF")
|
| 64 |
+
tk = tokens[k]
|
| 65 |
+
if not _UINT.match(tk) or len(tk) > 25:
|
| 66 |
+
raise Invalid(f"Parse error: {tk[:20]}")
|
| 67 |
+
v = int(tk)
|
| 68 |
+
if v >= 2 ** 64:
|
| 69 |
+
raise Invalid(f"Parse error: {tk[:20]}")
|
| 70 |
+
if v < 1 or D < v:
|
| 71 |
+
raise Invalid(f"Out of range: {v}")
|
| 72 |
+
r.append(v)
|
| 73 |
+
if len(tokens) > M:
|
| 74 |
+
raise Invalid("Too many outputs")
|
| 75 |
+
count = [0] * (D + 1)
|
| 76 |
+
for x in r:
|
| 77 |
+
count[x] += 1
|
| 78 |
+
for i in range(1, D + 1):
|
| 79 |
+
if count[i] > K:
|
| 80 |
+
raise Invalid(f"The number of edges to be repaired on day {i} has exceeded the limit. ({count[i]} > {K})")
|
| 81 |
+
iu = np.triu_indices(N, 1)
|
| 82 |
+
d0 = apsp(N, es, [True] * M)[iu]
|
| 83 |
+
num = 0
|
| 84 |
+
for day in range(1, D + 1):
|
| 85 |
+
dk = apsp(N, es, [x != day for x in r])[iu]
|
| 86 |
+
num += int((dk - d0).sum())
|
| 87 |
+
den = D * N * (N - 1) // 2
|
| 88 |
+
avg = float(num) / float(den) * 1000.0
|
| 89 |
+
return float(rust_round(avg)), {"num": num}
|
graders/ale_ahc019/check.py
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""ALE-Bench ahc019 (AHC 019 "Silhouette Block Puzzle Creation"): Python port of the official
|
| 2 |
+
tools/src/lib.rs (parse_output, compute_score, is_same with the tool's own rotation enumeration).
|
| 3 |
+
Answer = the contestant's stdout text. Lower is better."""
|
| 4 |
+
import re
|
| 5 |
+
|
| 6 |
+
from run import Invalid
|
| 7 |
+
|
| 8 |
+
_UINT = re.compile(r"\+?[0-9]+\Z") # Rust usize::from_str: optional '+', ASCII digits
|
| 9 |
+
_WS = re.compile(r"[\t\n\x0b\x0c\r ]+")
|
| 10 |
+
MAX_LEN = 1_000_000
|
| 11 |
+
D3 = [(0, 0, -1), (0, 0, 1), (0, -1, 0), (0, 1, 0), (-1, 0, 0), (1, 0, 0)]
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
def read(tokens, pos, lb, ub):
|
| 15 |
+
if pos >= len(tokens):
|
| 16 |
+
raise Invalid("Unexpected EOF")
|
| 17 |
+
t = tokens[pos]
|
| 18 |
+
if not _UINT.match(t) or len(t) > 25 or int(t) >= 2 ** 64:
|
| 19 |
+
raise Invalid(f"Parse error: {t[:20]}")
|
| 20 |
+
v = int(t)
|
| 21 |
+
if v < lb or ub < v:
|
| 22 |
+
raise Invalid(f"Out of range: {v}")
|
| 23 |
+
return v
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def parse_input(text):
|
| 27 |
+
tok = text.split()
|
| 28 |
+
D = int(tok[0])
|
| 29 |
+
k = 1
|
| 30 |
+
f, r = [], []
|
| 31 |
+
for _ in range(2):
|
| 32 |
+
f.append([[int(c) for c in tok[k + z]] for z in range(D)])
|
| 33 |
+
k += D
|
| 34 |
+
r.append([[int(c) for c in tok[k + z]] for z in range(D)])
|
| 35 |
+
k += D
|
| 36 |
+
return D, f, r
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
def normalize(b):
|
| 40 |
+
mx = min(p[0] for p in b)
|
| 41 |
+
my = min(p[1] for p in b)
|
| 42 |
+
mz = min(p[2] for p in b)
|
| 43 |
+
return [(x - mx, y - my, z - mz) for (x, y, z) in b]
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
def is_same(b1, b2):
|
| 47 |
+
if len(b1) != len(b2):
|
| 48 |
+
return False
|
| 49 |
+
b1 = sorted(normalize(b1))
|
| 50 |
+
b2 = normalize(b2)
|
| 51 |
+
max_x = max(p[0] for p in b2)
|
| 52 |
+
max_y = max(p[1] for p in b2)
|
| 53 |
+
max_z = max(p[2] for p in b2)
|
| 54 |
+
for i in range(6):
|
| 55 |
+
for _ in range(4):
|
| 56 |
+
b2.sort()
|
| 57 |
+
if b1 == b2:
|
| 58 |
+
return True
|
| 59 |
+
b2 = [(max_y - y, x, z) for (x, y, z) in b2]
|
| 60 |
+
max_x, max_y = max_y, max_x
|
| 61 |
+
if i & 1:
|
| 62 |
+
b2 = [(x, max_z - z, y) for (x, y, z) in b2]
|
| 63 |
+
max_y, max_z = max_z, max_y
|
| 64 |
+
else:
|
| 65 |
+
b2 = [(z, y, max_x - x) for (x, y, z) in b2]
|
| 66 |
+
max_x, max_z = max_z, max_x
|
| 67 |
+
return False
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
def check(inst, ans):
|
| 71 |
+
out = ans.get("output")
|
| 72 |
+
if not isinstance(out, str):
|
| 73 |
+
raise Invalid("output must be a string")
|
| 74 |
+
if len(out) > MAX_LEN:
|
| 75 |
+
raise Invalid(f"output longer than {MAX_LEN} characters")
|
| 76 |
+
if not out.isascii():
|
| 77 |
+
raise Invalid("output must be ASCII")
|
| 78 |
+
D, F, R = parse_input(inst["input"])
|
| 79 |
+
tokens = [t for t in _WS.split(out) if t]
|
| 80 |
+
n = read(tokens, 0, 0, 1000000)
|
| 81 |
+
b = []
|
| 82 |
+
p = 1
|
| 83 |
+
for i in range(2):
|
| 84 |
+
bi = [[[0] * D for _ in range(D)] for _ in range(D)]
|
| 85 |
+
for x in range(D):
|
| 86 |
+
for y in range(D):
|
| 87 |
+
for z in range(D):
|
| 88 |
+
bi[x][y][z] = read(tokens, p, 0, n)
|
| 89 |
+
p += 1
|
| 90 |
+
b.append(bi)
|
| 91 |
+
if len(tokens) > p:
|
| 92 |
+
raise Invalid("Too many outputs")
|
| 93 |
+
pos = [dict(), dict()]
|
| 94 |
+
for i in range(2):
|
| 95 |
+
bi = b[i]
|
| 96 |
+
f = [[0] * D for _ in range(D)]
|
| 97 |
+
r = [[0] * D for _ in range(D)]
|
| 98 |
+
visited = [[[False] * D for _ in range(D)] for _ in range(D)]
|
| 99 |
+
for x in range(D):
|
| 100 |
+
for y in range(D):
|
| 101 |
+
for z in range(D):
|
| 102 |
+
bid = bi[x][y][z]
|
| 103 |
+
if bid != 0:
|
| 104 |
+
f[z][x] = 1
|
| 105 |
+
r[z][y] = 1
|
| 106 |
+
lst = pos[i].setdefault(bid, [])
|
| 107 |
+
lst.append((x, y, z))
|
| 108 |
+
if len(lst) == 1:
|
| 109 |
+
visited[x][y][z] = True
|
| 110 |
+
stack = [(x, y, z)]
|
| 111 |
+
while stack:
|
| 112 |
+
cx, cy, cz = stack.pop()
|
| 113 |
+
for dx, dy, dz in D3:
|
| 114 |
+
x2, y2, z2 = cx + dx, cy + dy, cz + dz
|
| 115 |
+
if 0 <= x2 < D and 0 <= y2 < D and 0 <= z2 < D and bi[x2][y2][z2] == bid \
|
| 116 |
+
and not visited[x2][y2][z2]:
|
| 117 |
+
visited[x2][y2][z2] = True
|
| 118 |
+
stack.append((x2, y2, z2))
|
| 119 |
+
elif not visited[x][y][z]:
|
| 120 |
+
raise Invalid(f"block {bid} is not connected in the object {i + 1}")
|
| 121 |
+
if f != F[i]:
|
| 122 |
+
raise Invalid(f"The front silhouette for object {i + 1} does not match.")
|
| 123 |
+
if r != R[i]:
|
| 124 |
+
raise Invalid(f"The right silhouette for object {i + 1} does not match.")
|
| 125 |
+
used = set(pos[0]) | set(pos[1])
|
| 126 |
+
if len(used) != n:
|
| 127 |
+
raise Invalid("some block is not used")
|
| 128 |
+
s = 0.0
|
| 129 |
+
for bid in range(1, n + 1):
|
| 130 |
+
p0, p1 = pos[0].get(bid, []), pos[1].get(bid, [])
|
| 131 |
+
if not p0 or not p1:
|
| 132 |
+
s += float(len(p0) + len(p1))
|
| 133 |
+
elif is_same(p0, p1):
|
| 134 |
+
s += 1.0 / len(p0)
|
| 135 |
+
else:
|
| 136 |
+
raise Invalid(f"The shape of block {bid} differs between objects 1 and 2.")
|
| 137 |
+
return float(round_half_away(1e9 * s)), {"n": n}
|
| 138 |
+
|
| 139 |
+
|
| 140 |
+
def round_half_away(x):
|
| 141 |
+
import math
|
| 142 |
+
r = math.floor(x)
|
| 143 |
+
return r + 1 if x - r >= 0.5 else r
|
graders/ale_ahc021/check.py
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""ALE-Bench ahc021 (AHC 021 "Pyramid Sorting"): Python port of the official tools/src/lib.rs
|
| 2 |
+
(parse_output + compute_score + is_adj). Answer = the contestant's stdout text."""
|
| 3 |
+
import re
|
| 4 |
+
|
| 5 |
+
from run import Invalid
|
| 6 |
+
|
| 7 |
+
N = 30
|
| 8 |
+
_UINT = re.compile(r"\+?[0-9]+\Z") # Rust usize::from_str: optional '+', ASCII digits
|
| 9 |
+
_WS = re.compile(r"[\t\n\x0b\x0c\r ]+")
|
| 10 |
+
MAX_LEN = 1_000_000
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def read(tokens, pos, lb, ub):
|
| 14 |
+
if pos >= len(tokens):
|
| 15 |
+
raise Invalid("Unexpected EOF")
|
| 16 |
+
t = tokens[pos]
|
| 17 |
+
if not _UINT.match(t) or len(t) > 25 or int(t) >= 2 ** 64:
|
| 18 |
+
raise Invalid(f"Parse error: {t[:20]}")
|
| 19 |
+
v = int(t)
|
| 20 |
+
if v < lb or ub < v:
|
| 21 |
+
raise Invalid(f"Out of range: {v}")
|
| 22 |
+
return v
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def is_adj(p, q):
|
| 26 |
+
(x1, y1), (x2, y2) = p, q
|
| 27 |
+
if x1 == x2:
|
| 28 |
+
return y1 == y2 + 1 or y1 + 1 == y2
|
| 29 |
+
if x1 + 1 == x2:
|
| 30 |
+
return y1 == y2 or y1 + 1 == y2
|
| 31 |
+
if x1 == x2 + 1:
|
| 32 |
+
return y1 == y2 or y1 == y2 + 1
|
| 33 |
+
return False
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
def check(inst, ans):
|
| 37 |
+
out = ans.get("output")
|
| 38 |
+
if not isinstance(out, str):
|
| 39 |
+
raise Invalid("output must be a string")
|
| 40 |
+
if len(out) > MAX_LEN:
|
| 41 |
+
raise Invalid(f"output longer than {MAX_LEN} characters")
|
| 42 |
+
if not out.isascii():
|
| 43 |
+
raise Invalid("output must be ASCII")
|
| 44 |
+
vals = [int(t) for t in inst["input"].split()]
|
| 45 |
+
bs, k = [], 0
|
| 46 |
+
for i in range(N):
|
| 47 |
+
bs.append(vals[k:k + i + 1])
|
| 48 |
+
k += i + 1
|
| 49 |
+
tokens = [t for t in _WS.split(out) if t]
|
| 50 |
+
K = read(tokens, 0, 0, 10000)
|
| 51 |
+
if K == 0:
|
| 52 |
+
raise Invalid("K = 0 is not accepted in this conversion (perform at least one operation)")
|
| 53 |
+
p = 1
|
| 54 |
+
ops = []
|
| 55 |
+
for _ in range(K):
|
| 56 |
+
x1 = read(tokens, p, 0, N - 1)
|
| 57 |
+
y1 = read(tokens, p + 1, 0, x1)
|
| 58 |
+
x2 = read(tokens, p + 2, 0, N - 1)
|
| 59 |
+
y2 = read(tokens, p + 3, 0, x2)
|
| 60 |
+
p += 4
|
| 61 |
+
ops.append(((x1, y1), (x2, y2)))
|
| 62 |
+
if len(tokens) > p:
|
| 63 |
+
raise Invalid("Too many output")
|
| 64 |
+
for t, (a, b) in enumerate(ops):
|
| 65 |
+
if not is_adj(a, b):
|
| 66 |
+
raise Invalid(f"{a} and {b} are not adjacent (turn {t})")
|
| 67 |
+
bs[a[0]][a[1]], bs[b[0]][b[1]] = bs[b[0]][b[1]], bs[a[0]][a[1]]
|
| 68 |
+
num = 0
|
| 69 |
+
for x in range(N - 1):
|
| 70 |
+
for y in range(x + 1):
|
| 71 |
+
if bs[x][y] > bs[x + 1][y]:
|
| 72 |
+
num += 1
|
| 73 |
+
if bs[x][y] > bs[x + 1][y + 1]:
|
| 74 |
+
num += 1
|
| 75 |
+
score = (10000 - K) * 5 + 50000 if num == 0 else 50000 - num * 50
|
| 76 |
+
return float(score), {"K": K, "E": num}
|
graders/ale_ahc024/check.py
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""ALE-Bench ahc024 (Topological Map): exact Python port of the official tools/src/lib.rs
|
| 2 |
+
(parse_output + compute_score). Score = 1 + #squares of colour 0 in the LAST map output; WA -> Invalid."""
|
| 3 |
+
import re
|
| 4 |
+
|
| 5 |
+
from run import Invalid
|
| 6 |
+
|
| 7 |
+
MAX_CHARS = 2_000_000
|
| 8 |
+
_UINT = re.compile(r"\+?[0-9]+\Z")
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
def _text(ans):
|
| 12 |
+
s = ans.get("output")
|
| 13 |
+
if not isinstance(s, str):
|
| 14 |
+
raise Invalid("output must be a string")
|
| 15 |
+
if len(s) > MAX_CHARS:
|
| 16 |
+
raise Invalid(f"output longer than {MAX_CHARS} characters")
|
| 17 |
+
if any(not (" " <= ch <= "~" or ch in "\t\n\r") for ch in s):
|
| 18 |
+
raise Invalid("output may contain printable ASCII, spaces, tabs and newlines only")
|
| 19 |
+
return s
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def _read(tok, lb, ub):
|
| 23 |
+
if tok is None:
|
| 24 |
+
raise Invalid("Unexpected EOF")
|
| 25 |
+
if not _UINT.match(tok):
|
| 26 |
+
raise Invalid(f"Parse error: {tok}")
|
| 27 |
+
v = int(tok)
|
| 28 |
+
if v < lb or v > ub:
|
| 29 |
+
raise Invalid(f"Out of range: {v}")
|
| 30 |
+
return v
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
def parse_input(text):
|
| 34 |
+
t = text.split()
|
| 35 |
+
n, m = int(t[0]), int(t[1])
|
| 36 |
+
cs = [[int(t[2 + i * n + j]) for j in range(n)] for i in range(n)]
|
| 37 |
+
return n, m, cs
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
def _adj(cs, n, m):
|
| 41 |
+
adj = set()
|
| 42 |
+
for i in range(n):
|
| 43 |
+
for j in range(n):
|
| 44 |
+
c = cs[i][j]
|
| 45 |
+
if c != 0 and (i == 0 or j == 0 or i + 1 == n or j + 1 == n):
|
| 46 |
+
adj.add((0, c))
|
| 47 |
+
if i + 1 < n and c != cs[i + 1][j]:
|
| 48 |
+
d = cs[i + 1][j]
|
| 49 |
+
adj.add((min(c, d), max(c, d)))
|
| 50 |
+
if j + 1 < n and c != cs[i][j + 1]:
|
| 51 |
+
d = cs[i][j + 1]
|
| 52 |
+
adj.add((min(c, d), max(c, d)))
|
| 53 |
+
return adj
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
def check(inst, ans):
|
| 57 |
+
s = _text(ans)
|
| 58 |
+
n, m, cs = parse_input(inst["input"])
|
| 59 |
+
outs, out = [], []
|
| 60 |
+
for line in s.split("\n"):
|
| 61 |
+
line = line.strip()
|
| 62 |
+
if not line:
|
| 63 |
+
continue
|
| 64 |
+
toks = line.split()
|
| 65 |
+
row = [_read(toks[k] if k < len(toks) else None, 0, m) for k in range(n)]
|
| 66 |
+
if len(toks) > n:
|
| 67 |
+
raise Invalid("illegal output format")
|
| 68 |
+
out.append(row)
|
| 69 |
+
if len(out) == n:
|
| 70 |
+
outs.append(out)
|
| 71 |
+
out = []
|
| 72 |
+
if out:
|
| 73 |
+
raise Invalid("illegal output format")
|
| 74 |
+
if not outs:
|
| 75 |
+
raise Invalid("empty output")
|
| 76 |
+
d = outs[-1]
|
| 77 |
+
a0, a1 = _adj(cs, n, m), _adj(d, n, m)
|
| 78 |
+
if a0 != a1:
|
| 79 |
+
raise Invalid("adjacency differs from the original map")
|
| 80 |
+
done = [False] * (m + 1)
|
| 81 |
+
vis = [[False] * n for _ in range(n)]
|
| 82 |
+
for i in range(n):
|
| 83 |
+
for j in range(n):
|
| 84 |
+
if vis[i][j]:
|
| 85 |
+
continue
|
| 86 |
+
c = d[i][j]
|
| 87 |
+
if c > 0:
|
| 88 |
+
if done[c]:
|
| 89 |
+
raise Invalid(f"Squares of color {c} are not connected.")
|
| 90 |
+
done[c] = True
|
| 91 |
+
stack = [(i, j)]
|
| 92 |
+
vis[i][j] = True
|
| 93 |
+
outer = False
|
| 94 |
+
while stack:
|
| 95 |
+
x, y = stack.pop()
|
| 96 |
+
for dx, dy in ((0, 1), (1, 0), (0, -1), (-1, 0)):
|
| 97 |
+
x2, y2 = x + dx, y + dy
|
| 98 |
+
if not (0 <= x2 < n and 0 <= y2 < n):
|
| 99 |
+
outer = True
|
| 100 |
+
elif d[x][y] == d[x2][y2] and not vis[x2][y2]:
|
| 101 |
+
vis[x2][y2] = True
|
| 102 |
+
stack.append((x2, y2))
|
| 103 |
+
if c == 0 and not outer:
|
| 104 |
+
raise Invalid("Squares of color 0 are not connected.")
|
| 105 |
+
zeros = sum(row.count(0) for row in d)
|
| 106 |
+
return float(1 + zeros), {"zeros": zeros, "maps_output": len(outs)}
|
graders/ale_ahc026/check.py
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""ALE-Bench ahc026 (Stack of Boxes): exact Python port of the official tools/src/lib.rs
|
| 2 |
+
(parse_output + compute_score_details). Score = max(1, 10000 - V); WA (illegal op / unfinished) -> Invalid."""
|
| 3 |
+
import re
|
| 4 |
+
|
| 5 |
+
from run import Invalid
|
| 6 |
+
|
| 7 |
+
MAX_CHARS = 200_000
|
| 8 |
+
_UINT = re.compile(r"\+?[0-9]+\Z")
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
def _tokens(ans):
|
| 12 |
+
s = ans.get("output")
|
| 13 |
+
if not isinstance(s, str):
|
| 14 |
+
raise Invalid("output must be a string")
|
| 15 |
+
if len(s) > MAX_CHARS:
|
| 16 |
+
raise Invalid(f"output longer than {MAX_CHARS} characters")
|
| 17 |
+
if any(not (" " <= ch <= "~" or ch in "\t\n\r") for ch in s):
|
| 18 |
+
raise Invalid("output may contain printable ASCII, spaces, tabs and newlines only")
|
| 19 |
+
return s.split()
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def _read(toks, k, lb, ub):
|
| 23 |
+
if k >= len(toks):
|
| 24 |
+
raise Invalid("Unexpected EOF")
|
| 25 |
+
tok = toks[k]
|
| 26 |
+
if not _UINT.match(tok):
|
| 27 |
+
raise Invalid(f"Parse error: {tok}")
|
| 28 |
+
v = int(tok)
|
| 29 |
+
if v < lb or v > ub:
|
| 30 |
+
raise Invalid(f"Out of range: {v}")
|
| 31 |
+
return v
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
def parse_input(text):
|
| 35 |
+
t = list(map(int, text.split()))
|
| 36 |
+
n, m = t[0], t[1]
|
| 37 |
+
h = n // m
|
| 38 |
+
return n, m, [t[2 + i * h: 2 + (i + 1) * h] for i in range(m)]
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
def check(inst, ans):
|
| 42 |
+
toks = _tokens(ans)
|
| 43 |
+
n, m, bs = parse_input(inst["input"])
|
| 44 |
+
ops, k = [], 0
|
| 45 |
+
while k < len(toks):
|
| 46 |
+
ops.append((_read(toks, k, 1, n), _read(toks, k + 1, 0, m)))
|
| 47 |
+
k += 2
|
| 48 |
+
if len(ops) > 5000:
|
| 49 |
+
raise Invalid("Too many output")
|
| 50 |
+
where = {}
|
| 51 |
+
for i, st in enumerate(bs):
|
| 52 |
+
for b in st:
|
| 53 |
+
where[b] = i
|
| 54 |
+
cost, t = 0, 0
|
| 55 |
+
for v, to in ops:
|
| 56 |
+
if v not in where:
|
| 57 |
+
raise Invalid(f"Box {v} has already been taken out.")
|
| 58 |
+
i = where[v]
|
| 59 |
+
j = bs[i].index(v)
|
| 60 |
+
if to == 0:
|
| 61 |
+
if j + 1 != len(bs[i]):
|
| 62 |
+
raise Invalid(f"Box {v} is not at the top of the stack.")
|
| 63 |
+
if v != t + 1:
|
| 64 |
+
raise Invalid(f"Before carrying out box {v}, all boxes less than {v} must be carried out.")
|
| 65 |
+
bs[i].pop()
|
| 66 |
+
del where[v]
|
| 67 |
+
t += 1
|
| 68 |
+
else:
|
| 69 |
+
cost += len(bs[i]) - j + 1
|
| 70 |
+
to -= 1
|
| 71 |
+
if i != to:
|
| 72 |
+
moved = bs[i][j:]
|
| 73 |
+
bs[to].extend(moved)
|
| 74 |
+
del bs[i][j:]
|
| 75 |
+
for b in moved:
|
| 76 |
+
where[b] = to
|
| 77 |
+
if t < n:
|
| 78 |
+
raise Invalid(f"Not finished ({t} / {n})")
|
| 79 |
+
score = max(1, 10000 - cost)
|
| 80 |
+
return float(score), {"energy": cost, "operations": len(ops)}
|
graders/ale_ahc032/check.py
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""ALE-Bench ahc032 (Mod Stamp): exact Python port of the official tools/src/lib.rs
|
| 2 |
+
(parse_output + compute_score_details). Score = sum of (b_ij mod 998244353); WA -> Invalid.
|
| 3 |
+
Only deviation: L = 0 (the do-nothing output) is rejected."""
|
| 4 |
+
import re
|
| 5 |
+
|
| 6 |
+
from run import Invalid
|
| 7 |
+
|
| 8 |
+
MOD = 998244353
|
| 9 |
+
MAX_CHARS = 100_000
|
| 10 |
+
_UINT = re.compile(r"\+?[0-9]+\Z")
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def _tokens(ans):
|
| 14 |
+
s = ans.get("output")
|
| 15 |
+
if not isinstance(s, str):
|
| 16 |
+
raise Invalid("output must be a string")
|
| 17 |
+
if len(s) > MAX_CHARS:
|
| 18 |
+
raise Invalid(f"output longer than {MAX_CHARS} characters")
|
| 19 |
+
if any(not (" " <= ch <= "~" or ch in "\t\n\r") for ch in s):
|
| 20 |
+
raise Invalid("output may contain printable ASCII, spaces, tabs and newlines only")
|
| 21 |
+
return s.split()
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def _read(toks, k, lb, ub):
|
| 25 |
+
if k >= len(toks):
|
| 26 |
+
raise Invalid("Unexpected EOF")
|
| 27 |
+
tok = toks[k]
|
| 28 |
+
if not _UINT.match(tok):
|
| 29 |
+
raise Invalid(f"Parse error: {tok}")
|
| 30 |
+
v = int(tok)
|
| 31 |
+
if v < lb or v > ub:
|
| 32 |
+
raise Invalid(f"Out of range: {v}")
|
| 33 |
+
return v
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
def parse_input(text):
|
| 37 |
+
t = list(map(int, text.split()))
|
| 38 |
+
N, M, K = t[0], t[1], t[2]
|
| 39 |
+
p = 3
|
| 40 |
+
a = [t[p + i * N: p + (i + 1) * N] for i in range(N)]
|
| 41 |
+
p += N * N
|
| 42 |
+
s = []
|
| 43 |
+
for _ in range(M):
|
| 44 |
+
s.append([t[p + 3 * x: p + 3 * x + 3] for x in range(3)])
|
| 45 |
+
p += 9
|
| 46 |
+
return N, M, K, a, s
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
def check(inst, ans):
|
| 50 |
+
toks = _tokens(ans)
|
| 51 |
+
N, M, K, a, s = parse_input(inst["input"])
|
| 52 |
+
L = _read(toks, 0, 0, K)
|
| 53 |
+
if L == 0:
|
| 54 |
+
# conversion deviation (stricter than the tool): the empty plan L = 0 is not accepted
|
| 55 |
+
raise Invalid("this conversion requires at least one operation (L >= 1)")
|
| 56 |
+
ops, k = [], 1
|
| 57 |
+
for _ in range(L):
|
| 58 |
+
m = _read(toks, k, 0, M - 1)
|
| 59 |
+
i = _read(toks, k + 1, 0, N - 3)
|
| 60 |
+
j = _read(toks, k + 2, 0, N - 3)
|
| 61 |
+
ops.append((m, i, j))
|
| 62 |
+
k += 3
|
| 63 |
+
if k < len(toks):
|
| 64 |
+
raise Invalid("Too many outputs")
|
| 65 |
+
b = [list(r) for r in a]
|
| 66 |
+
for m, i, j in ops:
|
| 67 |
+
for x in range(3):
|
| 68 |
+
for y in range(3):
|
| 69 |
+
b[i + x][j + y] = (b[i + x][j + y] + s[m][x][y]) % MOD
|
| 70 |
+
score = sum(map(sum, b))
|
| 71 |
+
return float(score), {"operations": L}
|
graders/ale_ahc038/check.py
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""ALE-Bench ahc038 (Tree Robot Arm): exact Python port of the official tools/src/lib.rs
|
| 2 |
+
(parse_output + State::apply + compute_score_details). Absolute score (minimize) = number of turns K if every
|
| 3 |
+
target holds a takoyaki at the end, else 10^5 + 1000 (M - M'). Any tool error -> Invalid."""
|
| 4 |
+
import re
|
| 5 |
+
|
| 6 |
+
from run import Invalid
|
| 7 |
+
|
| 8 |
+
MAX_CHARS = 3_500_000
|
| 9 |
+
_UINT = re.compile(r"\+?[0-9]+\Z")
|
| 10 |
+
_INT = re.compile(r"[+-]?[0-9]+\Z")
|
| 11 |
+
DIJ = ((0, 1), (1, 0), (0, -1), (-1, 0))
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
def _tokens(ans):
|
| 15 |
+
s = ans.get("output")
|
| 16 |
+
if not isinstance(s, str):
|
| 17 |
+
raise Invalid("output must be a string")
|
| 18 |
+
if len(s) > MAX_CHARS:
|
| 19 |
+
raise Invalid(f"output longer than {MAX_CHARS} characters")
|
| 20 |
+
if any(not (" " <= ch <= "~" or ch in "\t\n\r") for ch in s):
|
| 21 |
+
raise Invalid("output may contain printable ASCII, spaces, tabs and newlines only")
|
| 22 |
+
return s.split()
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def _read(toks, k, lb, ub, signed=False):
|
| 26 |
+
if k >= len(toks):
|
| 27 |
+
raise Invalid("Unexpected EOF")
|
| 28 |
+
tok = toks[k]
|
| 29 |
+
if not (_INT if signed else _UINT).match(tok):
|
| 30 |
+
raise Invalid(f"Parse error: {tok}")
|
| 31 |
+
v = int(tok)
|
| 32 |
+
if signed and not (-2 ** 31 <= v < 2 ** 31):
|
| 33 |
+
raise Invalid(f"Parse error: {tok}")
|
| 34 |
+
if v < lb or v > ub:
|
| 35 |
+
raise Invalid(f"Out of range: {v}")
|
| 36 |
+
return v
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
def parse_input(text):
|
| 40 |
+
t = text.split()
|
| 41 |
+
N, M, V = int(t[0]), int(t[1]), int(t[2])
|
| 42 |
+
s = [[c == "1" for c in t[3 + i]] for i in range(N)]
|
| 43 |
+
tt = [[c == "1" for c in t[3 + N + i]] for i in range(N)]
|
| 44 |
+
return N, M, V, s, tt
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
def check(inst, ans):
|
| 48 |
+
toks = _tokens(ans)
|
| 49 |
+
N, M, Vmax, s, tgt = parse_input(inst["input"])
|
| 50 |
+
V = _read(toks, 0, 1, Vmax)
|
| 51 |
+
k = 1
|
| 52 |
+
pL = []
|
| 53 |
+
for u in range(1, V):
|
| 54 |
+
p = _read(toks, k, 0, u - 1)
|
| 55 |
+
L = _read(toks, k + 1, 1, N - 1)
|
| 56 |
+
pL.append((p, L))
|
| 57 |
+
k += 2
|
| 58 |
+
rx = _read(toks, k, 0, N - 1, signed=True)
|
| 59 |
+
ry = _read(toks, k + 1, 0, N - 1, signed=True)
|
| 60 |
+
k += 2
|
| 61 |
+
S = toks[k:]
|
| 62 |
+
for st in S:
|
| 63 |
+
if len(st) != 2 * V:
|
| 64 |
+
raise Invalid("Invalid operation length")
|
| 65 |
+
if len(S) > 100000:
|
| 66 |
+
raise Invalid("Too many output")
|
| 67 |
+
is_leaf = [True] * V
|
| 68 |
+
for p, _ in pL:
|
| 69 |
+
is_leaf[p] = False
|
| 70 |
+
dirs = [0] * V
|
| 71 |
+
has = [False] * V
|
| 72 |
+
board = [list(r) for r in s]
|
| 73 |
+
chain = [] # path root->u as list of vertices (excluding root)
|
| 74 |
+
for u in range(V):
|
| 75 |
+
c, w = [], u
|
| 76 |
+
while w > 0:
|
| 77 |
+
c.append(w)
|
| 78 |
+
w = pL[w - 1][0]
|
| 79 |
+
chain.append(c[::-1])
|
| 80 |
+
|
| 81 |
+
def get(u):
|
| 82 |
+
x, y, d = rx, ry, 0
|
| 83 |
+
for w in chain[u]:
|
| 84 |
+
d = (d + dirs[w]) % 4
|
| 85 |
+
L = pL[w - 1][1]
|
| 86 |
+
x += L * DIJ[d][0]
|
| 87 |
+
y += L * DIJ[d][1]
|
| 88 |
+
return x, y
|
| 89 |
+
|
| 90 |
+
for st in S:
|
| 91 |
+
c0 = st[0]
|
| 92 |
+
if c0 == "U":
|
| 93 |
+
rx -= 1
|
| 94 |
+
if rx < 0:
|
| 95 |
+
raise Invalid("The root coordinate is out of range.")
|
| 96 |
+
elif c0 == "D":
|
| 97 |
+
rx += 1
|
| 98 |
+
if rx == N:
|
| 99 |
+
raise Invalid("The root coordinate is out of range.")
|
| 100 |
+
elif c0 == "L":
|
| 101 |
+
ry -= 1
|
| 102 |
+
if ry < 0:
|
| 103 |
+
raise Invalid("The root coordinate is out of range.")
|
| 104 |
+
elif c0 == "R":
|
| 105 |
+
ry += 1
|
| 106 |
+
if ry == N:
|
| 107 |
+
raise Invalid("The root coordinate is out of range.")
|
| 108 |
+
elif c0 != ".":
|
| 109 |
+
raise Invalid(f"Invalid operation: {c0}")
|
| 110 |
+
for i in range(1, V):
|
| 111 |
+
c = st[i]
|
| 112 |
+
if c == "L":
|
| 113 |
+
dirs[i] = (dirs[i] + 3) % 4
|
| 114 |
+
elif c == "R":
|
| 115 |
+
dirs[i] = (dirs[i] + 1) % 4
|
| 116 |
+
elif c != ".":
|
| 117 |
+
raise Invalid(f"Invalid operation: {c}")
|
| 118 |
+
for i in range(V):
|
| 119 |
+
c = st[V + i]
|
| 120 |
+
if c == "P":
|
| 121 |
+
if not is_leaf[i]:
|
| 122 |
+
raise Invalid(f"The vertex {i} is not a leaf.")
|
| 123 |
+
x, y = get(i)
|
| 124 |
+
if x < 0 or y < 0 or x >= N or y >= N:
|
| 125 |
+
raise Invalid("The leaf coordinate is out of range.")
|
| 126 |
+
if has[i]:
|
| 127 |
+
if board[x][y]:
|
| 128 |
+
raise Invalid("You cannot put multiple takoyaki on the same square.")
|
| 129 |
+
has[i] = False
|
| 130 |
+
board[x][y] = True
|
| 131 |
+
else:
|
| 132 |
+
if not board[x][y]:
|
| 133 |
+
raise Invalid(f"({x}, {y}) does not contain takoyaki.")
|
| 134 |
+
has[i] = True
|
| 135 |
+
board[x][y] = False
|
| 136 |
+
elif c != ".":
|
| 137 |
+
raise Invalid(f"Invalid operation: {c}")
|
| 138 |
+
M2 = sum(1 for i in range(N) for j in range(N) if tgt[i][j] and board[i][j])
|
| 139 |
+
score = len(S) if M2 == M else 100000 + 1000 * (M - M2)
|
| 140 |
+
return float(score), {"turns": len(S), "on_target": M2}
|
graders/ale_ahc039/check.py
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""ALE-Bench ahc039 (Purse Seine Fishing): exact Python port of the official tools/src/lib.rs
|
| 2 |
+
(parse_output + compute_score_details), vectorised with numpy (integer arithmetic only).
|
| 3 |
+
Score = max(0, a - b + 1) for the LAST polygon output; tool errors -> Invalid."""
|
| 4 |
+
import re
|
| 5 |
+
|
| 6 |
+
import numpy as np
|
| 7 |
+
|
| 8 |
+
from run import Invalid
|
| 9 |
+
|
| 10 |
+
D = 100000
|
| 11 |
+
MAX_CHARS = 2_000_000
|
| 12 |
+
_INT = re.compile(r"[+-]?[0-9]+\Z")
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def _tokens(ans):
|
| 16 |
+
s = ans.get("output")
|
| 17 |
+
if not isinstance(s, str):
|
| 18 |
+
raise Invalid("output must be a string")
|
| 19 |
+
if len(s) > MAX_CHARS:
|
| 20 |
+
raise Invalid(f"output longer than {MAX_CHARS} characters")
|
| 21 |
+
if any(not (" " <= ch <= "~" or ch in "\t\n\r") for ch in s):
|
| 22 |
+
raise Invalid("output may contain printable ASCII, spaces, tabs and newlines only")
|
| 23 |
+
return s.split()
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def _read(toks, k, lb, ub):
|
| 27 |
+
if k >= len(toks):
|
| 28 |
+
raise Invalid("Unexpected EOF")
|
| 29 |
+
tok = toks[k]
|
| 30 |
+
if not _INT.match(tok) or not (-2 ** 63 <= int(tok) < 2 ** 63): # Rust i64 / usize parse
|
| 31 |
+
raise Invalid(f"Parse error: {tok}")
|
| 32 |
+
v = int(tok)
|
| 33 |
+
if v < lb or v > ub:
|
| 34 |
+
raise Invalid(f"Out of range: {v}")
|
| 35 |
+
return v
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
def parse_input(text):
|
| 39 |
+
t = list(map(int, text.split()))
|
| 40 |
+
N = t[0]
|
| 41 |
+
ps = np.array(t[1:1 + 4 * N], dtype=np.int64).reshape(2 * N, 2)
|
| 42 |
+
return N, ps
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
def check(inst, ans):
|
| 46 |
+
toks = _tokens(ans)
|
| 47 |
+
N, ps = parse_input(inst["input"])
|
| 48 |
+
polys, k = [], 0
|
| 49 |
+
while k < len(toks):
|
| 50 |
+
tok = toks[k]
|
| 51 |
+
if tok.startswith("-"): # m is read as usize: a sign '-' is a parse error
|
| 52 |
+
raise Invalid(f"Parse error: {tok}")
|
| 53 |
+
m = _read(toks, k, 4, 1000)
|
| 54 |
+
k += 1
|
| 55 |
+
poly = []
|
| 56 |
+
for _ in range(m):
|
| 57 |
+
poly.append((_read(toks, k, 0, D), _read(toks, k + 1, 0, D)))
|
| 58 |
+
k += 2
|
| 59 |
+
polys.append(poly)
|
| 60 |
+
out = polys[-1] if polys else []
|
| 61 |
+
m = len(out)
|
| 62 |
+
if m == 0:
|
| 63 |
+
return 1.0, {"mackerels": 0, "sardines": 0, "vertices": 0, "length": 0}
|
| 64 |
+
length = 0
|
| 65 |
+
for i in range(m):
|
| 66 |
+
p, q, r = out[i], out[(i + 1) % m], out[(i + 2) % m]
|
| 67 |
+
if p == q:
|
| 68 |
+
raise Invalid("Two consecutive vertices share the same coordinates.")
|
| 69 |
+
elif p[0] == q[0]:
|
| 70 |
+
length += abs(p[1] - q[1])
|
| 71 |
+
if q[0] == r[0] and (p[1] - q[1]) * (r[1] - q[1]) > 0:
|
| 72 |
+
raise Invalid("The polygon is self-intersecting.")
|
| 73 |
+
elif p[1] == q[1]:
|
| 74 |
+
length += abs(p[0] - q[0])
|
| 75 |
+
if q[1] == r[1] and (p[0] - q[0]) * (r[0] - q[0]) > 0:
|
| 76 |
+
raise Invalid("The polygon is self-intersecting.")
|
| 77 |
+
else:
|
| 78 |
+
raise Invalid(f"The {i}-th edge is not parallel to the axes.")
|
| 79 |
+
P = np.array(out, dtype=np.int64)
|
| 80 |
+
Q = np.roll(P, -1, axis=0)
|
| 81 |
+
xlo, xhi = np.minimum(P[:, 0], Q[:, 0]), np.maximum(P[:, 0], Q[:, 0])
|
| 82 |
+
ylo, yhi = np.minimum(P[:, 1], Q[:, 1]), np.maximum(P[:, 1], Q[:, 1])
|
| 83 |
+
idx = np.arange(m)
|
| 84 |
+
for off in range(2, m - 1): # non-adjacent edge pairs (i, i+off), as in the Rust loop
|
| 85 |
+
j = (idx + off) % m
|
| 86 |
+
hit = (np.maximum(xlo, xlo[j]) <= np.minimum(xhi, xhi[j])) & \
|
| 87 |
+
(np.maximum(ylo, ylo[j]) <= np.minimum(yhi, yhi[j]))
|
| 88 |
+
if hit.any():
|
| 89 |
+
raise Invalid("The polygon is self-intersecting.")
|
| 90 |
+
if length > 4 * D:
|
| 91 |
+
raise Invalid(f"The length is too long: {length}.")
|
| 92 |
+
rx, ry = ps[:, 0], ps[:, 1]
|
| 93 |
+
on_edge = np.zeros(len(ps), dtype=bool)
|
| 94 |
+
parity = np.zeros(len(ps), dtype=bool)
|
| 95 |
+
for e in range(m):
|
| 96 |
+
on_edge |= (xlo[e] <= rx) & (rx <= xhi[e]) & (ylo[e] <= ry) & (ry <= yhi[e])
|
| 97 |
+
if P[e, 1] == Q[e, 1]:
|
| 98 |
+
parity ^= (P[e, 1] > ry) & (xlo[e] <= rx) & (rx < xhi[e])
|
| 99 |
+
inside = on_edge | parity
|
| 100 |
+
a = int(inside[:N].sum())
|
| 101 |
+
b = int(inside[N:].sum())
|
| 102 |
+
return float(max(0, 1 + a - b)), {"mackerels": a, "sardines": b, "vertices": m, "length": length}
|
graders/ale_ahc041/check.py
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""ALE-Bench ahc041 (Christmas Tree Cutting): exact Python port of the official tools/src/lib.rs
|
| 2 |
+
(parse_output + to_tree_nodes + compute_score_details). Score = 1 + sum_v A_v (h_v + 1) for the LAST
|
| 3 |
+
parent vector output; tool errors -> Invalid."""
|
| 4 |
+
import re
|
| 5 |
+
|
| 6 |
+
from run import Invalid
|
| 7 |
+
|
| 8 |
+
MAX_CHARS = 2_000_000
|
| 9 |
+
_INT = re.compile(r"[+-]?[0-9]+\Z")
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
def _tokens(ans):
|
| 13 |
+
s = ans.get("output")
|
| 14 |
+
if not isinstance(s, str):
|
| 15 |
+
raise Invalid("output must be a string")
|
| 16 |
+
if len(s) > MAX_CHARS:
|
| 17 |
+
raise Invalid(f"output longer than {MAX_CHARS} characters")
|
| 18 |
+
if any(not (" " <= ch <= "~" or ch in "\t\n\r") for ch in s):
|
| 19 |
+
raise Invalid("output may contain printable ASCII, spaces, tabs and newlines only")
|
| 20 |
+
return s.split()
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def parse_input(text):
|
| 24 |
+
t = list(map(int, text.split()))
|
| 25 |
+
N, M, H = t[0], t[1], t[2]
|
| 26 |
+
A = t[3:3 + N]
|
| 27 |
+
p = 3 + N
|
| 28 |
+
edges = set()
|
| 29 |
+
for i in range(M):
|
| 30 |
+
edges.add((t[p + 2 * i], t[p + 2 * i + 1]))
|
| 31 |
+
return N, M, H, A, edges
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
def check(inst, ans):
|
| 35 |
+
toks = _tokens(ans)
|
| 36 |
+
N, M, H, A, edges = parse_input(inst["input"])
|
| 37 |
+
outs, k = [], 0
|
| 38 |
+
while k < len(toks):
|
| 39 |
+
par = []
|
| 40 |
+
for _ in range(N):
|
| 41 |
+
if k >= len(toks):
|
| 42 |
+
raise Invalid("Unexpected EOF")
|
| 43 |
+
tok = toks[k]
|
| 44 |
+
if not _INT.match(tok) or not (-2 ** 31 <= int(tok) < 2 ** 31): # Rust i32 parse
|
| 45 |
+
raise Invalid(f"Parse error: {tok}")
|
| 46 |
+
v = int(tok)
|
| 47 |
+
if not (-1 <= v < N):
|
| 48 |
+
raise Invalid(f"Out of range: {v}")
|
| 49 |
+
par.append(v)
|
| 50 |
+
k += 1
|
| 51 |
+
outs.append(par)
|
| 52 |
+
if not outs:
|
| 53 |
+
raise Invalid("empty output")
|
| 54 |
+
par = outs[-1]
|
| 55 |
+
children = [[] for _ in range(N)]
|
| 56 |
+
indeg = [0] * N
|
| 57 |
+
for v, p in enumerate(par):
|
| 58 |
+
if p == -1:
|
| 59 |
+
continue
|
| 60 |
+
if (min(v, p), max(v, p)) not in edges:
|
| 61 |
+
raise Invalid(f"Edge ({v}, {p}) is not included in the original graph.")
|
| 62 |
+
indeg[v] += 1
|
| 63 |
+
children[p].append(v)
|
| 64 |
+
h = [None] * N
|
| 65 |
+
for r in range(N):
|
| 66 |
+
if indeg[r] == 0:
|
| 67 |
+
stack = [(r, 0)]
|
| 68 |
+
while stack:
|
| 69 |
+
v, d = stack.pop()
|
| 70 |
+
h[v] = d
|
| 71 |
+
for c in children[v]:
|
| 72 |
+
stack.append((c, d + 1))
|
| 73 |
+
for v in range(N):
|
| 74 |
+
if h[v] is None:
|
| 75 |
+
raise Invalid(f"The connected component that contains vertex {v} is not a rooted tree.")
|
| 76 |
+
for v in range(N):
|
| 77 |
+
if h[v] > H:
|
| 78 |
+
raise Invalid(f"Vertex {v} is too high (h = {h[v]}).")
|
| 79 |
+
score = 1 + sum(A[v] * (h[v] + 1) for v in range(N))
|
| 80 |
+
return float(score), {"roots": sum(1 for p in par if p == -1), "max_height": max(h)}
|
graders/ale_ahc042/check.py
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""ALE-Bench ahc042 (Oni wa Soto, Fuku wa Uchi): exact Python port of the official tools/src/lib.rs
|
| 2 |
+
(parse_output + compute_score_details). Score = 8N^2 - T if all Oni removed and no Fukunokami removed,
|
| 3 |
+
else 4N^2 - N(X + Y); tool errors -> Invalid."""
|
| 4 |
+
import re
|
| 5 |
+
|
| 6 |
+
from run import Invalid
|
| 7 |
+
|
| 8 |
+
MAX_CHARS = 100_000
|
| 9 |
+
_UINT = re.compile(r"\+?[0-9]+\Z")
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
def _tokens(ans):
|
| 13 |
+
s = ans.get("output")
|
| 14 |
+
if not isinstance(s, str):
|
| 15 |
+
raise Invalid("output must be a string")
|
| 16 |
+
if len(s) > MAX_CHARS:
|
| 17 |
+
raise Invalid(f"output longer than {MAX_CHARS} characters")
|
| 18 |
+
if any(not (" " <= ch <= "~" or ch in "\t\n\r") for ch in s):
|
| 19 |
+
raise Invalid("output may contain printable ASCII, spaces, tabs and newlines only")
|
| 20 |
+
return s.split()
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def parse_input(text):
|
| 24 |
+
t = text.split()
|
| 25 |
+
n = int(t[0])
|
| 26 |
+
return n, [list(t[1 + i]) for i in range(n)]
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def check(inst, ans):
|
| 30 |
+
toks = _tokens(ans)
|
| 31 |
+
n, cs = parse_input(inst["input"])
|
| 32 |
+
out, k = [], 0
|
| 33 |
+
while k < len(toks):
|
| 34 |
+
d = toks[k]
|
| 35 |
+
if len(d) != 1:
|
| 36 |
+
raise Invalid(f"Parse error: {d}")
|
| 37 |
+
if not ("A" <= d <= "Z"):
|
| 38 |
+
raise Invalid(f"Out of range: {d}")
|
| 39 |
+
if k + 1 >= len(toks):
|
| 40 |
+
raise Invalid("Unexpected EOF")
|
| 41 |
+
tok = toks[k + 1]
|
| 42 |
+
if not _UINT.match(tok):
|
| 43 |
+
raise Invalid(f"Parse error: {tok}")
|
| 44 |
+
p = int(tok)
|
| 45 |
+
if p >= n:
|
| 46 |
+
raise Invalid(f"Out of range: {p}")
|
| 47 |
+
out.append((d, p))
|
| 48 |
+
k += 2
|
| 49 |
+
if len(out) > 4 * n * n:
|
| 50 |
+
raise Invalid("Too many operations")
|
| 51 |
+
for d, p in out:
|
| 52 |
+
if d == "L":
|
| 53 |
+
row = cs[p]
|
| 54 |
+
cs[p] = row[1:] + ["."]
|
| 55 |
+
elif d == "R":
|
| 56 |
+
row = cs[p]
|
| 57 |
+
cs[p] = ["."] + row[:-1]
|
| 58 |
+
elif d == "U":
|
| 59 |
+
for i in range(n - 1):
|
| 60 |
+
cs[i][p] = cs[i + 1][p]
|
| 61 |
+
cs[n - 1][p] = "."
|
| 62 |
+
elif d == "D":
|
| 63 |
+
for i in range(n - 1, 0, -1):
|
| 64 |
+
cs[i][p] = cs[i - 1][p]
|
| 65 |
+
cs[0][p] = "."
|
| 66 |
+
else:
|
| 67 |
+
raise Invalid(f"Invalid direction: {d}")
|
| 68 |
+
X = sum(r.count("x") for r in cs)
|
| 69 |
+
Y = 2 * n - sum(r.count("o") for r in cs)
|
| 70 |
+
T = len(out)
|
| 71 |
+
score = 8 * n * n - T if X == 0 and Y == 0 else 4 * n * n - n * (X + Y)
|
| 72 |
+
return float(score), {"T": T, "oni_left": X, "fuku_removed": Y}
|
graders/ale_ahc044/check.py
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""ALE-Bench ahc044 (Cleaning Up): exact Python port of the official tools/src/lib.rs
|
| 2 |
+
(parse_output + compute_score_details: a 500,000-week simulation). Score = 10^6 - E; tool errors -> Invalid."""
|
| 3 |
+
import re
|
| 4 |
+
|
| 5 |
+
from run import Invalid
|
| 6 |
+
|
| 7 |
+
MAX_CHARS = 100_000
|
| 8 |
+
_UINT = re.compile(r"\+?[0-9]+\Z")
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
def _tokens(ans):
|
| 12 |
+
s = ans.get("output")
|
| 13 |
+
if not isinstance(s, str):
|
| 14 |
+
raise Invalid("output must be a string")
|
| 15 |
+
if len(s) > MAX_CHARS:
|
| 16 |
+
raise Invalid(f"output longer than {MAX_CHARS} characters")
|
| 17 |
+
if any(not (" " <= ch <= "~" or ch in "\t\n\r") for ch in s):
|
| 18 |
+
raise Invalid("output may contain printable ASCII, spaces, tabs and newlines only")
|
| 19 |
+
return s.split()
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def _read(toks, k, lb, ub):
|
| 23 |
+
if k >= len(toks):
|
| 24 |
+
raise Invalid("Unexpected EOF")
|
| 25 |
+
tok = toks[k]
|
| 26 |
+
if not _UINT.match(tok):
|
| 27 |
+
raise Invalid(f"Parse error: {tok}")
|
| 28 |
+
v = int(tok)
|
| 29 |
+
if v < lb or v > ub:
|
| 30 |
+
raise Invalid(f"Out of range: {v}")
|
| 31 |
+
return v
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
def parse_input(text):
|
| 35 |
+
t = list(map(int, text.split()))
|
| 36 |
+
n, L = t[0], t[1]
|
| 37 |
+
return n, L, t[2:2 + n]
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
def check(inst, ans):
|
| 41 |
+
toks = _tokens(ans)
|
| 42 |
+
n, L, T = parse_input(inst["input"])
|
| 43 |
+
out, k = [], 0
|
| 44 |
+
while k < len(toks):
|
| 45 |
+
out.append((_read(toks, k, 0, n - 1), _read(toks, k + 1, 0, n - 1)))
|
| 46 |
+
k += 2
|
| 47 |
+
if len(out) > n:
|
| 48 |
+
raise Invalid("Number of lines in output is not N")
|
| 49 |
+
if len(out) != n:
|
| 50 |
+
raise Invalid("Number of lines in output is not N")
|
| 51 |
+
A = [a for a, _ in out]
|
| 52 |
+
B = [b for _, b in out]
|
| 53 |
+
counts = [0] * n
|
| 54 |
+
pos = 0
|
| 55 |
+
for _ in range(L):
|
| 56 |
+
c = counts[pos] + 1
|
| 57 |
+
counts[pos] = c
|
| 58 |
+
pos = A[pos] if c & 1 else B[pos]
|
| 59 |
+
E = sum(abs(counts[i] - T[i]) for i in range(n))
|
| 60 |
+
return float(2 * L - E), {"error": E}
|
graders/ale_ahc046/check.py
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""ALE-Bench ahc046 (Skating with Blocks): exact Python port of the official tools/src/lib.rs
|
| 2 |
+
(parse_output + compute_score_details). Score = M + 2NM - T if every target is visited in order, else the
|
| 3 |
+
number of visited squares (initial square included); tool errors -> Invalid."""
|
| 4 |
+
from run import Invalid
|
| 5 |
+
|
| 6 |
+
MAX_CHARS = 100_000
|
| 7 |
+
DIR = "UDLR"
|
| 8 |
+
DIJ = ((-1, 0), (1, 0), (0, -1), (0, 1))
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
def _tokens(ans):
|
| 12 |
+
s = ans.get("output")
|
| 13 |
+
if not isinstance(s, str):
|
| 14 |
+
raise Invalid("output must be a string")
|
| 15 |
+
if len(s) > MAX_CHARS:
|
| 16 |
+
raise Invalid(f"output longer than {MAX_CHARS} characters")
|
| 17 |
+
if any(not (" " <= ch <= "~" or ch in "\t\n\r") for ch in s):
|
| 18 |
+
raise Invalid("output may contain printable ASCII, spaces, tabs and newlines only")
|
| 19 |
+
return s.split()
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def _char(toks, k):
|
| 23 |
+
if k >= len(toks):
|
| 24 |
+
raise Invalid("Unexpected EOF")
|
| 25 |
+
c = toks[k]
|
| 26 |
+
if len(c) != 1:
|
| 27 |
+
raise Invalid(f"Parse error: {c}")
|
| 28 |
+
if not ("A" <= c <= "Z"):
|
| 29 |
+
raise Invalid(f"Out of range: {c}")
|
| 30 |
+
return c
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
def parse_input(text):
|
| 34 |
+
t = list(map(int, text.split()))
|
| 35 |
+
N, M = t[0], t[1]
|
| 36 |
+
return N, [(t[2 + 2 * k], t[3 + 2 * k]) for k in range(M)]
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
def check(inst, ans):
|
| 40 |
+
toks = _tokens(ans)
|
| 41 |
+
N, ps = parse_input(inst["input"])
|
| 42 |
+
out, k = [], 0
|
| 43 |
+
while k < len(toks):
|
| 44 |
+
a = _char(toks, k)
|
| 45 |
+
d = _char(toks, k + 1)
|
| 46 |
+
k += 2
|
| 47 |
+
if d not in DIR:
|
| 48 |
+
raise Invalid(f"Invalid direction: {d}")
|
| 49 |
+
if a not in "MSA":
|
| 50 |
+
raise Invalid(f"Invalid action: {a}")
|
| 51 |
+
out.append((a, DIR.index(d)))
|
| 52 |
+
if len(out) > 2 * N * len(ps):
|
| 53 |
+
raise Invalid(f"Too many actions: {len(out)}")
|
| 54 |
+
pi, pj = ps[0]
|
| 55 |
+
done = 1
|
| 56 |
+
block = [[False] * N for _ in range(N)]
|
| 57 |
+
for a, d in out:
|
| 58 |
+
di, dj = DIJ[d]
|
| 59 |
+
if a == "M":
|
| 60 |
+
ni, nj = pi + di, pj + dj
|
| 61 |
+
if not (0 <= ni < N and 0 <= nj < N):
|
| 62 |
+
raise Invalid(f"Out of range (M {DIR[d]})")
|
| 63 |
+
if block[ni][nj]:
|
| 64 |
+
raise Invalid(f"Blocked (M {DIR[d]})")
|
| 65 |
+
pi, pj = ni, nj
|
| 66 |
+
elif a == "S":
|
| 67 |
+
while True:
|
| 68 |
+
ni, nj = pi + di, pj + dj
|
| 69 |
+
if not (0 <= ni < N and 0 <= nj < N) or block[ni][nj]:
|
| 70 |
+
break
|
| 71 |
+
pi, pj = ni, nj
|
| 72 |
+
else:
|
| 73 |
+
ni, nj = pi + di, pj + dj
|
| 74 |
+
if not (0 <= ni < N and 0 <= nj < N):
|
| 75 |
+
raise Invalid(f"Out of range (A {DIR[d]})")
|
| 76 |
+
block[ni][nj] = not block[ni][nj]
|
| 77 |
+
if done < len(ps) and ps[done] == (pi, pj):
|
| 78 |
+
done += 1
|
| 79 |
+
if done < len(ps):
|
| 80 |
+
score = done
|
| 81 |
+
else:
|
| 82 |
+
score = len(ps) + 2 * N * len(ps) - len(out)
|
| 83 |
+
return float(score), {"visited": done, "T": len(out)}
|
graders/edge_apple_incremental/check.py
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""EdgeBench apple_incremental_game (AHC058 "Apple Incremental Game", EdgeBench CC-BY-4.0 adaptation).
|
| 2 |
+
|
| 3 |
+
Exact port of the task's official scorer tools/bin/tester (a Python script): parse the action lines
|
| 4 |
+
(strip; skip blank lines and lines starting with '#'), need >= T actions (extra ones are ignored), each
|
| 5 |
+
action is "-1" or "i j" with 0 <= i < L, 0 <= j < N and enough apples; then simulate T turns in exact
|
| 6 |
+
integer arithmetic. Score = round(1e5 * log2(S)) (0 if S <= 0). Only deviations: the output must be ASCII
|
| 7 |
+
and at most 200,000 characters (upstream int() would also accept e.g. non-ASCII digits).
|
| 8 |
+
"""
|
| 9 |
+
import math
|
| 10 |
+
|
| 11 |
+
from run import Invalid
|
| 12 |
+
|
| 13 |
+
MAX_CHARS = 200_000
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def parse_input(txt):
|
| 17 |
+
lines = txt.strip().split("\n")
|
| 18 |
+
N, L, T, K = map(int, lines[0].split())
|
| 19 |
+
A = list(map(int, lines[1].split()))
|
| 20 |
+
C = [list(map(int, lines[2 + i].split())) for i in range(L)]
|
| 21 |
+
return N, L, T, K, A, C
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def check(inst, ans):
|
| 25 |
+
out = ans.get("output")
|
| 26 |
+
if not isinstance(out, str):
|
| 27 |
+
raise Invalid("output must be a string")
|
| 28 |
+
if len(out) > MAX_CHARS:
|
| 29 |
+
raise Invalid(f"output longer than {MAX_CHARS} characters")
|
| 30 |
+
if not out.isascii():
|
| 31 |
+
raise Invalid("output must be ASCII")
|
| 32 |
+
N, L, T, K, A, C = parse_input(inst["input"])
|
| 33 |
+
actions = []
|
| 34 |
+
for line in out.strip().split("\n"):
|
| 35 |
+
line = line.strip()
|
| 36 |
+
if not line or line.startswith("#"):
|
| 37 |
+
continue
|
| 38 |
+
actions.append(line)
|
| 39 |
+
if len(actions) < T:
|
| 40 |
+
raise Invalid(f"expected {T} actions, got {len(actions)}")
|
| 41 |
+
B = [[1] * N for _ in range(L)]
|
| 42 |
+
P = [[0] * N for _ in range(L)]
|
| 43 |
+
apples = K
|
| 44 |
+
for t in range(T):
|
| 45 |
+
action = actions[t].strip()
|
| 46 |
+
if action != "-1":
|
| 47 |
+
parts = action.split()
|
| 48 |
+
if len(parts) != 2:
|
| 49 |
+
raise Invalid(f"invalid action format at turn {t}: {action[:50]}")
|
| 50 |
+
try:
|
| 51 |
+
i, j = int(parts[0]), int(parts[1])
|
| 52 |
+
except ValueError:
|
| 53 |
+
raise Invalid(f"invalid action at turn {t}: {action[:50]}")
|
| 54 |
+
if not (0 <= i < L and 0 <= j < N):
|
| 55 |
+
raise Invalid(f"invalid machine at turn {t}: ({i}, {j})")
|
| 56 |
+
cost = C[i][j] * (P[i][j] + 1)
|
| 57 |
+
if apples < cost:
|
| 58 |
+
raise Invalid(f"not enough apples at turn {t}: have {apples}, need {cost}")
|
| 59 |
+
apples -= cost
|
| 60 |
+
P[i][j] += 1
|
| 61 |
+
for j in range(N):
|
| 62 |
+
apples += A[j] * B[0][j] * P[0][j]
|
| 63 |
+
for i in range(1, L):
|
| 64 |
+
for j in range(N):
|
| 65 |
+
B[i - 1][j] += B[i][j] * P[i][j]
|
| 66 |
+
score = 0 if apples <= 0 else round(1e5 * math.log2(apples))
|
| 67 |
+
return float(score), {"apples_log2": math.log2(apples) if apples > 0 else None}
|
graders/edge_grid_turing_robot/check.py
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""EdgeBench grid_turing_robot (AHC056 "Grid Turing Robot", EdgeBench CC-BY-4.0 adaptation).
|
| 2 |
+
|
| 3 |
+
Exact port of the task's official scorer (tools/bin/tester -> tools/src/verifier.py, Python): parse
|
| 4 |
+
"C Q M", N rows of initial colours, M rules "c q A S D" (extra tokens on a line are ignored, as upstream),
|
| 5 |
+
range/duplicate checks, then simulate at most T steps (stop when no rule exists for the current (colour,
|
| 6 |
+
state)); V = destinations reached in order. Score = C + Q if V = K, else 2 N^4 + (K - V) N^2 (lower is
|
| 7 |
+
better; a valid answer that misses destinations is still valid, with the penalty score).
|
| 8 |
+
Deviations: output must be ASCII and at most 1,000,000 characters.
|
| 9 |
+
"""
|
| 10 |
+
from run import Invalid
|
| 11 |
+
|
| 12 |
+
MAX_CHARS = 1_000_000
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def parse_input(txt):
|
| 16 |
+
lines = txt.split("\n")
|
| 17 |
+
N, K, T = map(int, lines[0].split())
|
| 18 |
+
v = [lines[1 + i].strip() for i in range(N)]
|
| 19 |
+
h = [lines[1 + N + i].strip() for i in range(N - 1)]
|
| 20 |
+
tg = [tuple(map(int, lines[2 * N + i].split())) for i in range(K)]
|
| 21 |
+
return N, K, T, v, h, tg
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def check(inst, ans):
|
| 25 |
+
out = ans.get("output")
|
| 26 |
+
if not isinstance(out, str):
|
| 27 |
+
raise Invalid("output must be a string")
|
| 28 |
+
if len(out) > MAX_CHARS:
|
| 29 |
+
raise Invalid(f"output longer than {MAX_CHARS} characters")
|
| 30 |
+
if not out.isascii():
|
| 31 |
+
raise Invalid("output must be ASCII")
|
| 32 |
+
N, K, T, v, h, targets = parse_input(inst["input"])
|
| 33 |
+
s = out.replace("\r\n", "\n").replace("\r", "\n") # text-mode universal newlines, as upstream open()
|
| 34 |
+
lines = s.split("\n")
|
| 35 |
+
if s.endswith("\n"):
|
| 36 |
+
lines = lines[:-1]
|
| 37 |
+
if not lines:
|
| 38 |
+
raise Invalid("Empty output")
|
| 39 |
+
idx = 0
|
| 40 |
+
try:
|
| 41 |
+
parts = lines[idx].split()
|
| 42 |
+
C, Q, M = int(parts[0]), int(parts[1]), int(parts[2])
|
| 43 |
+
idx += 1
|
| 44 |
+
if not (1 <= C <= N ** 4):
|
| 45 |
+
raise Invalid(f"C={C} out of range [1, {N ** 4}]")
|
| 46 |
+
if not (1 <= Q <= N ** 4):
|
| 47 |
+
raise Invalid(f"Q={Q} out of range [1, {N ** 4}]")
|
| 48 |
+
if not (0 <= M <= T):
|
| 49 |
+
raise Invalid(f"M={M} out of range [0, {T}]")
|
| 50 |
+
grid = []
|
| 51 |
+
for i in range(N):
|
| 52 |
+
row = list(map(int, lines[idx + i].split()))
|
| 53 |
+
if len(row) != N:
|
| 54 |
+
raise Invalid(f"Row {i}: expected {N} colors, got {len(row)}")
|
| 55 |
+
for c in row:
|
| 56 |
+
if not (0 <= c < C):
|
| 57 |
+
raise Invalid(f"Color {c} out of range [0, {C - 1}]")
|
| 58 |
+
grid.append(row)
|
| 59 |
+
idx += N
|
| 60 |
+
rules = {}
|
| 61 |
+
for i in range(M):
|
| 62 |
+
parts = lines[idx + i].split()
|
| 63 |
+
c, q, a, st, d = int(parts[0]), int(parts[1]), int(parts[2]), int(parts[3]), parts[4]
|
| 64 |
+
if (c, q) in rules:
|
| 65 |
+
raise Invalid(f"Duplicate rule for (c={c}, q={q})")
|
| 66 |
+
if not (0 <= c < C):
|
| 67 |
+
raise Invalid(f"Rule color {c} out of range")
|
| 68 |
+
if not (0 <= q < Q):
|
| 69 |
+
raise Invalid(f"Rule state {q} out of range")
|
| 70 |
+
if not (0 <= a < C):
|
| 71 |
+
raise Invalid(f"Rule repaint {a} out of range")
|
| 72 |
+
if not (0 <= st < Q):
|
| 73 |
+
raise Invalid(f"Rule new state {st} out of range")
|
| 74 |
+
if d not in ("U", "D", "L", "R", "S"):
|
| 75 |
+
raise Invalid(f"Invalid direction: {d}")
|
| 76 |
+
rules[(c, q)] = (a, st, d)
|
| 77 |
+
except Invalid:
|
| 78 |
+
raise
|
| 79 |
+
except Exception as e:
|
| 80 |
+
raise Invalid(f"Output format error: {type(e).__name__}")
|
| 81 |
+
|
| 82 |
+
def can_move(i, j, d):
|
| 83 |
+
if d == "U":
|
| 84 |
+
return i > 0 and h[i - 1][j] == "0"
|
| 85 |
+
if d == "D":
|
| 86 |
+
return i < N - 1 and h[i][j] == "0"
|
| 87 |
+
if d == "L":
|
| 88 |
+
return j > 0 and v[i][j - 1] == "0"
|
| 89 |
+
if d == "R":
|
| 90 |
+
return j < N - 1 and v[i][j] == "0"
|
| 91 |
+
return False
|
| 92 |
+
|
| 93 |
+
step = {"U": (-1, 0), "D": (1, 0), "L": (0, -1), "R": (0, 1)}
|
| 94 |
+
ci, cj = targets[0]
|
| 95 |
+
cq = 0
|
| 96 |
+
visited, nxt = 1, 1
|
| 97 |
+
for _ in range(T):
|
| 98 |
+
key = (grid[ci][cj], cq)
|
| 99 |
+
if key not in rules:
|
| 100 |
+
break
|
| 101 |
+
a, st, d = rules[key]
|
| 102 |
+
grid[ci][cj] = a
|
| 103 |
+
cq = st
|
| 104 |
+
if d != "S" and can_move(ci, cj, d):
|
| 105 |
+
ci += step[d][0]
|
| 106 |
+
cj += step[d][1]
|
| 107 |
+
if nxt < K and (ci, cj) == targets[nxt]:
|
| 108 |
+
visited += 1
|
| 109 |
+
nxt += 1
|
| 110 |
+
if visited == K:
|
| 111 |
+
score = C + Q
|
| 112 |
+
else:
|
| 113 |
+
score = 2 * N ** 4 + (K - visited) * N ** 2
|
| 114 |
+
return float(score), {"C": C, "Q": Q, "visited": visited, "K": K}
|
graders/fco_mds/check.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""FrontierCO MDS: minimum dominating set of a fixed graph (vertices 1..n). Score = |D| (minimize).
|
| 2 |
+
|
| 3 |
+
Port of FrontierCO MDS/config.py eval_func: D must be a list of distinct existing vertices and every
|
| 4 |
+
vertex must be in D or adjacent to a vertex of D. Stricter than upstream: entries must be JSON integers
|
| 5 |
+
(upstream accepted any hashable equal to a node id, e.g. 3.0 or True for vertex 1).
|
| 6 |
+
"""
|
| 7 |
+
from run import Invalid, int_list
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def check(inst, ans):
|
| 11 |
+
n = inst["n"]
|
| 12 |
+
D = ans.get("dominating_set")
|
| 13 |
+
if not isinstance(D, list) or not D or len(D) > n:
|
| 14 |
+
raise Invalid(f"dominating_set must be a non-empty list of at most {n} vertices")
|
| 15 |
+
D = int_list(D, None, 1, n, "dominating_set")
|
| 16 |
+
if len(set(D)) != len(D):
|
| 17 |
+
raise Invalid("duplicate vertices in dominating_set")
|
| 18 |
+
dom = bytearray(n + 1)
|
| 19 |
+
for v in D:
|
| 20 |
+
dom[v] = 1
|
| 21 |
+
inD = bytes(dom)
|
| 22 |
+
for u, v in inst["edges"]:
|
| 23 |
+
if inD[u]:
|
| 24 |
+
dom[v] = 1
|
| 25 |
+
if inD[v]:
|
| 26 |
+
dom[u] = 1
|
| 27 |
+
missing = dom.count(0, 1)
|
| 28 |
+
if missing:
|
| 29 |
+
first = dom.index(0, 1)
|
| 30 |
+
raise Invalid(f"{missing} vertices are not dominated (e.g. vertex {first})")
|
| 31 |
+
return float(len(D)), {"size": len(D)}
|
graders/fcs_beacon/check.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""FrontierCS algorithmic/302 (Spectrum-Friendly Beacon String). Answer {"s": "<string>"}: length n, letters among the
|
| 2 |
+
first k, letter i used exactly c_i times. Objective (minimize) = sum of W[s_t][s_t+1] over adjacent pairs + sum over
|
| 3 |
+
motifs of w * (#occurrences, overlaps counted; duplicate motifs add up), exact integers (port of chk.cc)."""
|
| 4 |
+
from run import Invalid
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
def _parse(text):
|
| 8 |
+
t = text.split()
|
| 9 |
+
n, k = int(t[0]), int(t[1])
|
| 10 |
+
cnt = list(map(int, t[2:2 + k]))
|
| 11 |
+
p = 2 + k
|
| 12 |
+
W = [list(map(int, t[p + i * k:p + (i + 1) * k])) for i in range(k)]
|
| 13 |
+
p += k * k
|
| 14 |
+
m = int(t[p]); p += 1
|
| 15 |
+
mot = {}
|
| 16 |
+
for i in range(m):
|
| 17 |
+
s, w = t[p + 2 * i], int(t[p + 2 * i + 1])
|
| 18 |
+
mot[s] = mot.get(s, 0) + w
|
| 19 |
+
return n, k, cnt, W, mot
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def penalty(s, k, W, mot):
|
| 23 |
+
a = [ord(ch) - 97 for ch in s]
|
| 24 |
+
tot = sum(W[a[i]][a[i + 1]] for i in range(len(a) - 1))
|
| 25 |
+
lens = sorted({len(x) for x in mot})
|
| 26 |
+
for L in lens:
|
| 27 |
+
for i in range(len(s) - L + 1):
|
| 28 |
+
w = mot.get(s[i:i + L])
|
| 29 |
+
if w:
|
| 30 |
+
tot += w
|
| 31 |
+
return tot
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
def check(inst, ans):
|
| 35 |
+
n, k, cnt, W, mot = _parse(inst["input"])
|
| 36 |
+
s = ans.get("s")
|
| 37 |
+
if not isinstance(s, str) or len(s) != n:
|
| 38 |
+
raise Invalid(f"s must be a string of length {n}")
|
| 39 |
+
got = [0] * k
|
| 40 |
+
for ch in s:
|
| 41 |
+
i = ord(ch) - 97
|
| 42 |
+
if not 0 <= i < k:
|
| 43 |
+
raise Invalid("character outside the alphabet")
|
| 44 |
+
got[i] += 1
|
| 45 |
+
if got != cnt:
|
| 46 |
+
raise Invalid("wrong letter counts")
|
| 47 |
+
X = penalty(s, k, W, mot)
|
| 48 |
+
return float(X), {"penalty": X}
|
graders/fcs_digit_grid/check.py
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""FrontierCS algorithmic/110: 8 x 14 digit grid; X = largest integer such that every number 1..X can be
|
| 2 |
+
read along a king-move walk (8 directions, revisits allowed, no stay moves, no jumps). Maximize X.
|
| 3 |
+
|
| 4 |
+
Port of upstream chk.cc: exactly 8 whitespace-separated tokens of exactly 14 digits each, nothing after.
|
| 5 |
+
canRead(s) = frontier propagation over cells, as upstream. Exact (integers only).
|
| 6 |
+
"""
|
| 7 |
+
from run import Invalid
|
| 8 |
+
|
| 9 |
+
H, W = 8, 14
|
| 10 |
+
MAX_CHARS = 10_000
|
| 11 |
+
X_CAP = 10 ** 7 # cannot be reached: an 8x14 grid has < 112 * 8^6 readable 7-digit walks
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
def _neighbors():
|
| 15 |
+
nb = []
|
| 16 |
+
for y in range(H):
|
| 17 |
+
for x in range(W):
|
| 18 |
+
m = 0
|
| 19 |
+
for dy in (-1, 0, 1):
|
| 20 |
+
for dx in (-1, 0, 1):
|
| 21 |
+
if (dy or dx) and 0 <= y + dy < H and 0 <= x + dx < W:
|
| 22 |
+
m |= 1 << ((y + dy) * W + x + dx)
|
| 23 |
+
nb.append(m)
|
| 24 |
+
return nb
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
NB = _neighbors()
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
def prefix_score(rows):
|
| 31 |
+
flat = "".join(rows)
|
| 32 |
+
by_digit = [0] * 10
|
| 33 |
+
for i, ch in enumerate(flat):
|
| 34 |
+
by_digit[ord(ch) - 48] |= 1 << i
|
| 35 |
+
# expand(mask) = union of neighbourhoods of the cells in mask
|
| 36 |
+
def can_read(s):
|
| 37 |
+
fr = by_digit[ord(s[0]) - 48]
|
| 38 |
+
for ch in s[1:]:
|
| 39 |
+
if not fr:
|
| 40 |
+
return False
|
| 41 |
+
nxt = 0
|
| 42 |
+
m = fr
|
| 43 |
+
while m:
|
| 44 |
+
low = m & -m
|
| 45 |
+
nxt |= NB[low.bit_length() - 1]
|
| 46 |
+
m ^= low
|
| 47 |
+
fr = nxt & by_digit[ord(ch) - 48]
|
| 48 |
+
return fr != 0
|
| 49 |
+
X = 0
|
| 50 |
+
while X < X_CAP and can_read(str(X + 1)):
|
| 51 |
+
X += 1
|
| 52 |
+
return X
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
def check(inst, ans):
|
| 56 |
+
s = ans.get("output")
|
| 57 |
+
if not isinstance(s, str):
|
| 58 |
+
raise Invalid("output must be a string")
|
| 59 |
+
if len(s) > MAX_CHARS or not s.isascii():
|
| 60 |
+
raise Invalid("output too long or not ASCII")
|
| 61 |
+
t = s.split()
|
| 62 |
+
if len(t) != H:
|
| 63 |
+
raise Invalid(f"expected exactly {H} rows (whitespace-separated tokens), got {len(t)}")
|
| 64 |
+
for r, row in enumerate(t):
|
| 65 |
+
if len(row) != W or any(not ("0" <= ch <= "9") for ch in row):
|
| 66 |
+
raise Invalid(f"row {r + 1} must be exactly {W} digits")
|
| 67 |
+
X = prefix_score(t)
|
| 68 |
+
return float(X), {"X": X}
|
graders/fcs_gcd_chain/check.py
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""FrontierCS algorithmic/41 (Brilliant Sequence of Umbrellas): a_1 < ... < a_k in [1, n] with
|
| 2 |
+
gcd(a_i, a_{i-1}) > gcd(a_{i-1}, a_{i-2}) for all i >= 3. Maximize V = k * (a_1 + ... + a_k).
|
| 3 |
+
|
| 4 |
+
Port of upstream chk.cc: k in [1, 10^6], k integers in [1, n], strictly increasing, strictly increasing
|
| 5 |
+
consecutive gcds; nothing after the sequence. V is computed exactly (upstream: long double).
|
| 6 |
+
"""
|
| 7 |
+
import re
|
| 8 |
+
from math import gcd
|
| 9 |
+
|
| 10 |
+
from run import Invalid
|
| 11 |
+
|
| 12 |
+
_INT = re.compile(r"(0|-?[1-9][0-9]*)\Z")
|
| 13 |
+
MAX_CHARS = 2_000_000
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def _int(tok, lo, hi, name):
|
| 17 |
+
if not _INT.match(tok):
|
| 18 |
+
raise Invalid(f"{name}: expected an integer, got {tok[:20]!r}")
|
| 19 |
+
v = int(tok)
|
| 20 |
+
if v < lo or v > hi:
|
| 21 |
+
raise Invalid(f"{name} = {v} out of range [{lo}, {hi}]")
|
| 22 |
+
return v
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def check(inst, ans):
|
| 26 |
+
n = inst["n"]
|
| 27 |
+
s = ans.get("output")
|
| 28 |
+
if not isinstance(s, str):
|
| 29 |
+
raise Invalid("output must be a string")
|
| 30 |
+
if len(s) > MAX_CHARS or not s.isascii():
|
| 31 |
+
raise Invalid("output too long or not ASCII")
|
| 32 |
+
t = s.split()
|
| 33 |
+
if not t:
|
| 34 |
+
raise Invalid("empty output")
|
| 35 |
+
k = _int(t[0], 1, 10 ** 6, "k")
|
| 36 |
+
if len(t) != 1 + k:
|
| 37 |
+
raise Invalid(f"expected exactly {k} numbers after k, got {len(t) - 1}")
|
| 38 |
+
a = [_int(x, 1, n, "a_i") for x in t[1:]]
|
| 39 |
+
for i in range(1, k):
|
| 40 |
+
if a[i] <= a[i - 1]:
|
| 41 |
+
raise Invalid("sequence is not strictly increasing")
|
| 42 |
+
if k >= 3:
|
| 43 |
+
g = gcd(a[1], a[0])
|
| 44 |
+
for i in range(2, k):
|
| 45 |
+
h = gcd(a[i], a[i - 1])
|
| 46 |
+
if h <= g:
|
| 47 |
+
raise Invalid(f"gcds are not strictly increasing at position {i + 1}")
|
| 48 |
+
g = h
|
| 49 |
+
V = k * sum(a)
|
| 50 |
+
return float(V), {"k": k, "V": V}
|
graders/fcs_inc_subseq_perm/check.py
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""FrontierCS algorithmic/33 (Permutation, modified): for each k_i, a permutation of {0..n-1} with exactly k_i
|
| 2 |
+
increasing subsequences (the empty one included). Objective = max over i of n_i (minimize).
|
| 3 |
+
|
| 4 |
+
Port of upstream checker.cpp: per k, n then n integers in [0, n-1], all distinct, exact count == k (upstream
|
| 5 |
+
uses a Fenwick tree saturating at 1e18 + 1, equivalent since k <= 1e18); nothing after the last permutation.
|
| 6 |
+
Deviation: n <= 1000 per permutation (upstream: 5000) to bound grading time; any n > 116 is already worse than
|
| 7 |
+
the trivial baseline of every task.
|
| 8 |
+
"""
|
| 9 |
+
import re
|
| 10 |
+
|
| 11 |
+
from run import Invalid
|
| 12 |
+
|
| 13 |
+
_INT = re.compile(r"(0|-?[1-9][0-9]*)\Z")
|
| 14 |
+
NMAX = 1000
|
| 15 |
+
MAX_CHARS = 600_000
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def _int(tok, lo, hi, name):
|
| 19 |
+
if not _INT.match(tok):
|
| 20 |
+
raise Invalid(f"{name}: expected an integer, got {tok[:20]!r}")
|
| 21 |
+
v = int(tok)
|
| 22 |
+
if v < lo or v > hi:
|
| 23 |
+
raise Invalid(f"{name} = {v} out of range [{lo}, {hi}]")
|
| 24 |
+
return v
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def count_inc(p):
|
| 28 |
+
n = len(p)
|
| 29 |
+
bit = [0] * (n + 2)
|
| 30 |
+
total = 1 # the empty subsequence
|
| 31 |
+
for v in p:
|
| 32 |
+
i, s = v + 1, 0 # sum over values < v (Fenwick over 1..n)
|
| 33 |
+
while i > 0:
|
| 34 |
+
s += bit[i]
|
| 35 |
+
i -= i & -i
|
| 36 |
+
me = s + 1 # subsequences ending at v
|
| 37 |
+
total += me
|
| 38 |
+
i = v + 1 + 1
|
| 39 |
+
while i <= n + 1:
|
| 40 |
+
bit[i] += me
|
| 41 |
+
i += i & -i
|
| 42 |
+
return total
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
def check(inst, ans):
|
| 46 |
+
ks = inst["ks"]
|
| 47 |
+
s = ans.get("output")
|
| 48 |
+
if not isinstance(s, str):
|
| 49 |
+
raise Invalid("output must be a string")
|
| 50 |
+
if len(s) > MAX_CHARS or not s.isascii():
|
| 51 |
+
raise Invalid("output too long or not ASCII")
|
| 52 |
+
t = s.split()
|
| 53 |
+
pos, mx = 0, 0
|
| 54 |
+
for idx, k in enumerate(ks):
|
| 55 |
+
if pos >= len(t):
|
| 56 |
+
raise Invalid(f"output ended before permutation {idx + 1}")
|
| 57 |
+
n = _int(t[pos], 1, NMAX, "n")
|
| 58 |
+
pos += 1
|
| 59 |
+
if pos + n > len(t):
|
| 60 |
+
raise Invalid(f"output ended inside permutation {idx + 1}")
|
| 61 |
+
p = [_int(x, 0, n - 1, "perm[i]") for x in t[pos:pos + n]]
|
| 62 |
+
pos += n
|
| 63 |
+
if len(set(p)) != n:
|
| 64 |
+
raise Invalid(f"permutation {idx + 1} contains duplicates")
|
| 65 |
+
if count_inc(p) != k:
|
| 66 |
+
raise Invalid(f"permutation {idx + 1} does not have exactly {k} increasing subsequences")
|
| 67 |
+
mx = max(mx, n)
|
| 68 |
+
if pos != len(t):
|
| 69 |
+
raise Invalid("extra tokens after the last permutation")
|
| 70 |
+
return float(mx), {"max_n": mx}
|
graders/fcs_inverse_paths/check.py
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""FrontierCS algorithmic/58 (Inverse Counting Path): an n x n 0/1 grid (n <= 300) whose number of monotone
|
| 2 |
+
(right/down) paths from (1,1) to (n,n) through 1-cells is exactly x. Minimize n.
|
| 3 |
+
|
| 4 |
+
Port of upstream chk.cc validation (n in [1, 300], n*n entries each 0 or 1, nothing after), with one fix:
|
| 5 |
+
upstream compares the path count with x only modulo 998244353 and modulo 1e9+7 (a hash; a grid with a
|
| 6 |
+
different, colliding count would pass). We compare the exact big-integer count.
|
| 7 |
+
"""
|
| 8 |
+
import re
|
| 9 |
+
|
| 10 |
+
from run import Invalid
|
| 11 |
+
|
| 12 |
+
_INT = re.compile(r"(0|-?[1-9][0-9]*)\Z")
|
| 13 |
+
MAX_CHARS = 400_000
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def check(inst, ans):
|
| 17 |
+
x = inst["x"]
|
| 18 |
+
s = ans.get("output")
|
| 19 |
+
if not isinstance(s, str):
|
| 20 |
+
raise Invalid("output must be a string")
|
| 21 |
+
if len(s) > MAX_CHARS or not s.isascii():
|
| 22 |
+
raise Invalid("output too long or not ASCII")
|
| 23 |
+
t = s.split()
|
| 24 |
+
if not t or not _INT.match(t[0]):
|
| 25 |
+
raise Invalid("first token must be the integer n")
|
| 26 |
+
n = int(t[0])
|
| 27 |
+
if n < 1 or n > 300:
|
| 28 |
+
raise Invalid(f"n = {n} out of range [1, 300]")
|
| 29 |
+
if len(t) != 1 + n * n:
|
| 30 |
+
raise Invalid(f"expected exactly {n * n} grid entries after n, got {len(t) - 1}")
|
| 31 |
+
cells = t[1:]
|
| 32 |
+
if any(v not in ("0", "1") for v in cells):
|
| 33 |
+
bad = next(v for v in cells if v not in ("0", "1"))
|
| 34 |
+
raise Invalid(f"grid entries must be 0 or 1 (got {bad[:20]!r})")
|
| 35 |
+
g = [[cells[i * n + j] == "1" for j in range(n)] for i in range(n)]
|
| 36 |
+
prev = [0] * n
|
| 37 |
+
for i in range(n):
|
| 38 |
+
cur = [0] * n
|
| 39 |
+
row = g[i]
|
| 40 |
+
for j in range(n):
|
| 41 |
+
if row[j]:
|
| 42 |
+
if i == 0 and j == 0:
|
| 43 |
+
cur[j] = 1
|
| 44 |
+
else:
|
| 45 |
+
cur[j] = prev[j] + (cur[j - 1] if j else 0)
|
| 46 |
+
prev = cur
|
| 47 |
+
cnt = prev[n - 1]
|
| 48 |
+
if cnt != x:
|
| 49 |
+
raise Invalid(f"the grid has {cnt if cnt < 10 ** 30 else 'more than 1e30'} paths, not {x}")
|
| 50 |
+
return float(n), {"n": n}
|
graders/fcs_lis_lds_split/check.py
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""FrontierCS algorithmic/227: split a permutation p of 1..n into four disjoint subsequences a, b, c, d (every
|
| 2 |
+
element used exactly once, each list in the order the values appear in p). Objective (maximize)
|
| 3 |
+
= LIS(a) + LDS(b) + LIS(c) + LDS(d) (strict, exact integers). Answer {"a": [...], "b": [...], "c": [...], "d": [...]},
|
| 4 |
+
lists of VALUES of p. chk.cc does not range-check the values (out-of-range values are undefined behaviour); we do."""
|
| 5 |
+
from bisect import bisect_left
|
| 6 |
+
|
| 7 |
+
from run import Invalid, int_list
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def _lis(v):
|
| 11 |
+
dp = []
|
| 12 |
+
for x in v:
|
| 13 |
+
i = bisect_left(dp, x)
|
| 14 |
+
if i == len(dp):
|
| 15 |
+
dp.append(x)
|
| 16 |
+
else:
|
| 17 |
+
dp[i] = x
|
| 18 |
+
return len(dp)
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def check(inst, ans):
|
| 22 |
+
t = inst["input"].split()
|
| 23 |
+
n = int(t[0])
|
| 24 |
+
p = list(map(int, t[1:1 + n]))
|
| 25 |
+
loc = [0] * (n + 1)
|
| 26 |
+
for i, x in enumerate(p):
|
| 27 |
+
loc[x] = i
|
| 28 |
+
seen = [False] * (n + 1)
|
| 29 |
+
lists = {}
|
| 30 |
+
for k in "abcd":
|
| 31 |
+
v = int_list(ans.get(k), None, 1, n, k)
|
| 32 |
+
for i, x in enumerate(v):
|
| 33 |
+
if seen[x]:
|
| 34 |
+
raise Invalid(f"element {x} appears twice")
|
| 35 |
+
seen[x] = True
|
| 36 |
+
if i and loc[v[i - 1]] > loc[x]:
|
| 37 |
+
raise Invalid(f"list {k} is not in the order of p at element {x}")
|
| 38 |
+
lists[k] = v
|
| 39 |
+
if sum(len(v) for v in lists.values()) != n:
|
| 40 |
+
raise Invalid("a, b, c, d must partition all n elements")
|
| 41 |
+
la, lc = _lis(lists["a"]), _lis(lists["c"])
|
| 42 |
+
lb, ld = _lis(lists["b"][::-1]), _lis(lists["d"][::-1])
|
| 43 |
+
tot = la + lb + lc + ld
|
| 44 |
+
return float(tot), {"lis_a": la, "lds_b": lb, "lis_c": lc, "lds_d": ld}
|
graders/fcs_max3sat/check.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""FrontierCS algorithmic/176 Max-3-SAT on a fixed CNF. Answer: {"assignment": [x_1..x_n]}, x_i in {0,1} (1 = TRUE).
|
| 2 |
+
Objective (maximize) = number of satisfied clauses (exact integer). Port of chk.cc; the official checker
|
| 3 |
+
ignores trailing tokens, we require exactly n values."""
|
| 4 |
+
from run import Invalid, int_list
|
| 5 |
+
|
| 6 |
+
K = 3
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
def _parse(text):
|
| 10 |
+
t = text.split()
|
| 11 |
+
n, m = int(t[0]), int(t[1])
|
| 12 |
+
v = list(map(int, t[2:2 + K * m]))
|
| 13 |
+
return n, m, [v[K * i:K * i + K] for i in range(m)]
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def check(inst, ans):
|
| 17 |
+
n, m, clauses = _parse(inst["input"])
|
| 18 |
+
x = int_list(ans.get("assignment"), n, 0, 1, "assignment")
|
| 19 |
+
sat = 0
|
| 20 |
+
for c in clauses:
|
| 21 |
+
for lit in c:
|
| 22 |
+
if (x[lit - 1] == 1) if lit > 0 else (x[-lit - 1] == 0):
|
| 23 |
+
sat += 1
|
| 24 |
+
break
|
| 25 |
+
return float(sat), {"satisfied": sat, "m": m}
|
graders/fcs_maxcut/check.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""FrontierCS algorithmic/192 Max-Cut on a fixed graph. Answer: {"side": [s_1..s_n]}, s_i in {0,1}.
|
| 2 |
+
Objective (maximize) = number of edges whose endpoints get different sides (exact integer).
|
| 3 |
+
Port of chk.cc; the official checker reads n integers and ignores trailing tokens, we require exactly n."""
|
| 4 |
+
from run import Invalid, int_list
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
def _parse(text):
|
| 8 |
+
t = text.split()
|
| 9 |
+
n, m = int(t[0]), int(t[1])
|
| 10 |
+
e = [(int(t[2 + 2 * i]), int(t[3 + 2 * i])) for i in range(m)]
|
| 11 |
+
return n, m, e
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
def check(inst, ans):
|
| 15 |
+
n, m, edges = _parse(inst["input"])
|
| 16 |
+
s = int_list(ans.get("side"), n, 0, 1, "side")
|
| 17 |
+
cut = sum(1 for u, v in edges if s[u - 1] != s[v - 1])
|
| 18 |
+
return float(cut), {"cut": cut, "m": m}
|
graders/fcs_mult_partial_sums/check.py
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""FrontierCS algorithmic/83: completely multiplicative f: {1..n} -> {+1,-1} minimizing max_k |sum_{i<=k} f(i)|.
|
| 2 |
+
|
| 3 |
+
Port of upstream check.cpp: exactly n integers, each of absolute value 1, nothing after them;
|
| 4 |
+
f(xy) = f(x) f(y) whenever xy <= n. Upstream enumerates all pairs (x, y); we check the equivalent
|
| 5 |
+
f(1) = 1 and f(i) = f(p) f(i / p) for p = smallest prime factor of i (induction gives full complete
|
| 6 |
+
multiplicativity, and the converse is immediate). Objective M = max prefix |sum| (minimize), exact integers.
|
| 7 |
+
"""
|
| 8 |
+
import re
|
| 9 |
+
|
| 10 |
+
import numpy as np
|
| 11 |
+
|
| 12 |
+
from run import Invalid
|
| 13 |
+
|
| 14 |
+
_INT = re.compile(r"(0|-?[1-9][0-9]*)\Z")
|
| 15 |
+
MAX_CHARS = 4_000_000
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def check(inst, ans):
|
| 19 |
+
n = inst["n"]
|
| 20 |
+
s = ans.get("output")
|
| 21 |
+
if not isinstance(s, str):
|
| 22 |
+
raise Invalid("output must be a string")
|
| 23 |
+
if len(s) > MAX_CHARS:
|
| 24 |
+
raise Invalid("output too long")
|
| 25 |
+
if not s.isascii():
|
| 26 |
+
raise Invalid("output must be ASCII")
|
| 27 |
+
t = s.split()
|
| 28 |
+
if len(t) != n:
|
| 29 |
+
raise Invalid(f"expected exactly {n} integers, got {len(t)}")
|
| 30 |
+
bad = [x for x in set(t) if x not in ("1", "-1")]
|
| 31 |
+
if bad:
|
| 32 |
+
b = bad[0]
|
| 33 |
+
raise Invalid(f"|f(i)| must be 1 (token {b[:20]!r})" if _INT.match(b) else f"expected an integer, got {b[:20]!r}")
|
| 34 |
+
f = np.empty(n + 1, dtype=np.int64)
|
| 35 |
+
f[0] = 0
|
| 36 |
+
f[1:] = np.where(np.array(t) == "1", 1, -1)
|
| 37 |
+
if f[1] != 1:
|
| 38 |
+
raise Invalid("f(1) must be 1 (f(1) = f(1*1) = f(1)^2)")
|
| 39 |
+
spf = np.arange(n + 1, dtype=np.int64)
|
| 40 |
+
for p in range(2, int(n ** 0.5) + 1):
|
| 41 |
+
if spf[p] == p:
|
| 42 |
+
seg = spf[p * p::p]
|
| 43 |
+
np.copyto(seg, p, where=(seg == np.arange(p * p, n + 1, p)))
|
| 44 |
+
i = np.arange(2, n + 1)
|
| 45 |
+
p = spf[2:]
|
| 46 |
+
ok = f[2:] == f[p] * f[i // p]
|
| 47 |
+
if not ok.all():
|
| 48 |
+
j = int(i[np.argmin(ok)])
|
| 49 |
+
raise Invalid(f"not completely multiplicative: f({j}) != f({int(spf[j])}) * f({j // int(spf[j])})")
|
| 50 |
+
M = int(np.abs(np.cumsum(f[1:])).max())
|
| 51 |
+
return float(M), {"M": M}
|
graders/fcs_no_rectangle/check.py
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""FrontierCS algorithmic/27: rectangle-free point set in an n x m grid (Zarankiewicz z(n,m;2,2)).
|
| 2 |
+
|
| 3 |
+
Port of the upstream testlib checker chk.cc (validation part): k in [0, n*m], k points (r, c) with
|
| 4 |
+
1 <= r <= n, 1 <= c <= m, no duplicates, no two rows sharing two columns. Objective = k (maximize).
|
| 5 |
+
Output is parsed like testlib: whitespace-separated tokens, integers in canonical form.
|
| 6 |
+
Unlike upstream (which comments out readEof) trailing tokens are rejected.
|
| 7 |
+
"""
|
| 8 |
+
import re
|
| 9 |
+
|
| 10 |
+
import numpy as np
|
| 11 |
+
|
| 12 |
+
from run import Invalid
|
| 13 |
+
|
| 14 |
+
_INT = re.compile(r"(0|-?[1-9][0-9]*)\Z")
|
| 15 |
+
MAX_CHARS = 3_000_000
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def _tokens(ans):
|
| 19 |
+
s = ans.get("output")
|
| 20 |
+
if not isinstance(s, str):
|
| 21 |
+
raise Invalid("output must be a string")
|
| 22 |
+
if len(s) > MAX_CHARS:
|
| 23 |
+
raise Invalid("output too long")
|
| 24 |
+
if any(not (32 <= ord(ch) < 127 or ch in "\t\r\n") for ch in s):
|
| 25 |
+
raise Invalid("output must be printable ASCII")
|
| 26 |
+
return s.split()
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def _int(tok, lo, hi, name):
|
| 30 |
+
if not _INT.match(tok):
|
| 31 |
+
raise Invalid(f"{name}: expected an integer, got {tok[:20]!r}")
|
| 32 |
+
v = int(tok)
|
| 33 |
+
if v < lo or v > hi:
|
| 34 |
+
raise Invalid(f"{name} = {v} out of range [{lo}, {hi}]")
|
| 35 |
+
return v
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
def check(inst, ans):
|
| 39 |
+
n, m = inst["n"], inst["m"]
|
| 40 |
+
t = _tokens(ans)
|
| 41 |
+
if not t:
|
| 42 |
+
raise Invalid("empty output")
|
| 43 |
+
k = _int(t[0], 1, n * m, "k") # upstream allows k = 0 (0 points); we require k >= 1
|
| 44 |
+
if len(t) != 1 + 2 * k:
|
| 45 |
+
raise Invalid(f"expected exactly {2 * k} integers after k, got {len(t) - 1}")
|
| 46 |
+
M = np.zeros((n, m), dtype=np.int8)
|
| 47 |
+
for i in range(k):
|
| 48 |
+
r = _int(t[1 + 2 * i], 1, n, "r")
|
| 49 |
+
c = _int(t[2 + 2 * i], 1, m, "c")
|
| 50 |
+
if M[r - 1, c - 1]:
|
| 51 |
+
raise Invalid(f"duplicate point ({r}, {c})")
|
| 52 |
+
M[r - 1, c - 1] = 1
|
| 53 |
+
if k and n > 1 and m > 1:
|
| 54 |
+
A = M if n <= m else M.T
|
| 55 |
+
A = A.astype(np.float64)
|
| 56 |
+
G = A @ A.T # exact: entries <= max(n, m) <= 1e5
|
| 57 |
+
np.fill_diagonal(G, 0)
|
| 58 |
+
if G.max() >= 2:
|
| 59 |
+
i, j = np.unravel_index(int(np.argmax(G)), G.shape)
|
| 60 |
+
raise Invalid(f"rectangle: two {'rows' if n <= m else 'columns'} ({i + 1}, {j + 1}) share >= 2 points")
|
| 61 |
+
return float(k), {"k": k}
|
graders/fcs_prime_retune/check.py
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""FrontierCS algorithmic/314 (Prime Resonance Retuning). Answer {"retuners": [[v, d], ...]}: at most k distinct
|
| 2 |
+
nodes v in 1..n with shifts 1 <= d < m. A retuner adds d (mod m) to every node of the subtree of v. Objective
|
| 3 |
+
(minimize) F = sum_j w_j * (|P| - C_j) + sum of c_v over retuners, where P = primes < m and C_j = number of primes
|
| 4 |
+
of P occurring among the final residues in the subtree of s_j (exact integers; port of chk.cc)."""
|
| 5 |
+
import numpy as np
|
| 6 |
+
|
| 7 |
+
from run import Invalid, int_list
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def _parse(text):
|
| 11 |
+
t = text.split()
|
| 12 |
+
n, m, T, k = map(int, t[:4])
|
| 13 |
+
p = 4
|
| 14 |
+
a = [int(x) % m for x in t[p:p + n]]; p += n
|
| 15 |
+
c = list(map(int, t[p:p + n])); p += n
|
| 16 |
+
adj = [[] for _ in range(n + 1)]
|
| 17 |
+
for i in range(n - 1):
|
| 18 |
+
u, v = int(t[p + 2 * i]), int(t[p + 2 * i + 1])
|
| 19 |
+
adj[u].append(v)
|
| 20 |
+
adj[v].append(u)
|
| 21 |
+
p += 2 * (n - 1)
|
| 22 |
+
obs = [(int(t[p + 2 * j]), int(t[p + 2 * j + 1])) for j in range(T)]
|
| 23 |
+
return n, m, k, a, c, adj, obs
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def check(inst, ans):
|
| 27 |
+
n, m, k, a, c, adj, obs = _parse(inst["input"])
|
| 28 |
+
R = ans.get("retuners")
|
| 29 |
+
if not isinstance(R, list) or len(R) > k:
|
| 30 |
+
raise Invalid(f"retuners must be a list of at most k = {k} pairs")
|
| 31 |
+
x = [0] * (n + 1)
|
| 32 |
+
cost = 0
|
| 33 |
+
for r in R:
|
| 34 |
+
v, d = int_list(r, 2, None, None, "retuner")
|
| 35 |
+
if not (1 <= v <= n) or not (1 <= d <= m - 1):
|
| 36 |
+
raise Invalid(f"retuner {r} out of range (1 <= v <= {n}, 1 <= d <= {m - 1})")
|
| 37 |
+
if x[v]:
|
| 38 |
+
raise Invalid(f"node {v} used twice")
|
| 39 |
+
x[v] = d
|
| 40 |
+
cost += c[v - 1]
|
| 41 |
+
# root at 1: BFS order / parents, then preorder positions for subtrees
|
| 42 |
+
par = [0] * (n + 1)
|
| 43 |
+
order = [1]
|
| 44 |
+
seen = [False] * (n + 1)
|
| 45 |
+
seen[1] = True
|
| 46 |
+
for u in order:
|
| 47 |
+
for w in adj[u]:
|
| 48 |
+
if not seen[w]:
|
| 49 |
+
seen[w] = True
|
| 50 |
+
par[w] = u
|
| 51 |
+
order.append(w)
|
| 52 |
+
cs = [0] * (n + 1)
|
| 53 |
+
for u in order:
|
| 54 |
+
cs[u] = ((cs[par[u]] if par[u] else 0) + x[u]) % m
|
| 55 |
+
children = [[] for _ in range(n + 1)]
|
| 56 |
+
for u in order[1:]:
|
| 57 |
+
children[par[u]].append(u)
|
| 58 |
+
tin, tout, euler = [0] * (n + 1), [0] * (n + 1), []
|
| 59 |
+
st = [(1, False)]
|
| 60 |
+
while st:
|
| 61 |
+
u, leave = st.pop()
|
| 62 |
+
if leave:
|
| 63 |
+
tout[u] = len(euler) - 1
|
| 64 |
+
else:
|
| 65 |
+
tin[u] = len(euler)
|
| 66 |
+
euler.append(u)
|
| 67 |
+
st.append((u, True))
|
| 68 |
+
for w in reversed(children[u]):
|
| 69 |
+
st.append((w, False))
|
| 70 |
+
sieve = [True] * max(m, 2)
|
| 71 |
+
primes = []
|
| 72 |
+
for q in range(2, m):
|
| 73 |
+
if sieve[q]:
|
| 74 |
+
primes.append(q)
|
| 75 |
+
for z in range(2 * q, m, q):
|
| 76 |
+
sieve[z] = False
|
| 77 |
+
pid = {q: i for i, q in enumerate(primes)}
|
| 78 |
+
P = len(primes)
|
| 79 |
+
if P == 0:
|
| 80 |
+
return float(cost), {"F": cost}
|
| 81 |
+
M = np.zeros((n + 1, P), dtype=np.int32) # prefix counts over Euler positions
|
| 82 |
+
for pos, u in enumerate(euler):
|
| 83 |
+
M[pos + 1] = M[pos]
|
| 84 |
+
i = pid.get((a[u - 1] + cs[u]) % m)
|
| 85 |
+
if i is not None:
|
| 86 |
+
M[pos + 1, i] += 1
|
| 87 |
+
pen = 0
|
| 88 |
+
for s, w in obs:
|
| 89 |
+
cov = int(np.count_nonzero(M[tout[s] + 1] - M[tin[s]]))
|
| 90 |
+
pen += w * (P - cov)
|
| 91 |
+
F = pen + cost
|
| 92 |
+
return float(F), {"F": F, "penalty": pen, "retuner_cost": cost}
|
graders/fcs_shortcut3hop/check.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""FrontierCS algorithmic/239: shortcut edges so that a path 0->1->...->n has hop-diameter <= 3.
|
| 2 |
+
Answer {"triples": [[a, b, c], ...]}: in order, each triple adds edge a->c and requires edges a->b and b->c to
|
| 3 |
+
exist at that moment (chain edges i->i+1 exist initially). Afterwards every pair v < u must be joined by a
|
| 4 |
+
directed path of at most 3 edges. Objective (minimize) = number of triples (as in chk.cc, a triple whose edge
|
| 5 |
+
a->c already exists is legal and still counts). Reachability is checked exactly with 0/1 matrix products."""
|
| 6 |
+
import numpy as np
|
| 7 |
+
|
| 8 |
+
from run import Invalid, int_list
|
| 9 |
+
|
| 10 |
+
MAX_TRIPLES = 300000
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def check(inst, ans):
|
| 14 |
+
n = int(inst["input"].split()[0])
|
| 15 |
+
tr = ans.get("triples")
|
| 16 |
+
if not isinstance(tr, list) or len(tr) > MAX_TRIPLES:
|
| 17 |
+
raise Invalid(f"triples must be a list of at most {MAX_TRIPLES} triples")
|
| 18 |
+
N = n + 1
|
| 19 |
+
G = np.zeros((N, N), dtype=bool)
|
| 20 |
+
idx = np.arange(n)
|
| 21 |
+
G[idx, idx + 1] = True
|
| 22 |
+
for t in tr:
|
| 23 |
+
a, b, c = int_list(t, 3, 0, n, "triple")
|
| 24 |
+
if not (G[a, b] and G[b, c]):
|
| 25 |
+
raise Invalid(f"cannot add {a}->{c}: edges {a}->{b} and {b}->{c} must both exist")
|
| 26 |
+
G[a, c] = True
|
| 27 |
+
R1 = (G | np.eye(N, dtype=bool)).astype(np.float32)
|
| 28 |
+
R2 = (R1 @ R1) > 0.5
|
| 29 |
+
R3 = (R2.astype(np.float32) @ R1) > 0.5
|
| 30 |
+
if not np.triu(R3, 1).sum() == N * (N - 1) // 2:
|
| 31 |
+
bad = np.argwhere(np.triu(~R3, 1))[0]
|
| 32 |
+
raise Invalid(f"vertex {bad[1]} is not reachable from {bad[0]} within 3 edges")
|
| 33 |
+
return float(len(tr)), {"m": len(tr)}
|
graders/fcs_swap_shift/check.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""FrontierCS algorithmic/247: transform A into B with operations (i, j), i < j: A_i <- A_j - 1, A_j <- A_i + 1.
|
| 2 |
+
Answer {"ops": [[i, j], ...]} (1-based, at most 100000 ops); must end exactly at B. Objective (minimize) = number
|
| 3 |
+
of operations. Port of chk.cc's simulation (only "Yes" instances are used, so the Yes/No token is implicit)."""
|
| 4 |
+
from run import Invalid, int_list
|
| 5 |
+
|
| 6 |
+
MAX_OPS = 100000
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
def check(inst, ans):
|
| 10 |
+
t = inst["input"].split()
|
| 11 |
+
n = int(t[0])
|
| 12 |
+
A = list(map(int, t[1:1 + n]))
|
| 13 |
+
B = list(map(int, t[1 + n:1 + 2 * n]))
|
| 14 |
+
ops = ans.get("ops")
|
| 15 |
+
if not isinstance(ops, list) or len(ops) > MAX_OPS:
|
| 16 |
+
raise Invalid(f"ops must be a list of at most {MAX_OPS} pairs")
|
| 17 |
+
for op in ops:
|
| 18 |
+
i, j = int_list(op, 2, 1, n, "op")
|
| 19 |
+
if i >= j:
|
| 20 |
+
raise Invalid(f"operation ({i}, {j}) needs i < j")
|
| 21 |
+
A[i - 1], A[j - 1] = A[j - 1] - 1, A[i - 1] + 1
|
| 22 |
+
if A != B:
|
| 23 |
+
raise Invalid("final sequence does not equal B")
|
| 24 |
+
return float(len(ops)), {"m": len(ops)}
|
graders/fcs_xor_sidon/check.py
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""FrontierCS algorithmic/111: S subset of {1..n} with all pairwise XORs a^b (a < b) distinct (a Sidon set
|
| 2 |
+
in the group (Z/2)^K restricted to 1..n). Maximize |S|.
|
| 3 |
+
|
| 4 |
+
Port of upstream chk.cc: m, then m distinct integers in [1, n]; reject if m(m-1)/2 > 2^K (K = bit width
|
| 5 |
+
with 2^K > n), then all pairwise XORs must be distinct. Upstream allows m = 0 (0 points); we require m >= 1.
|
| 6 |
+
Upstream comments say extra tokens are ignored, but testlib rejects them at exit; so do we.
|
| 7 |
+
"""
|
| 8 |
+
import re
|
| 9 |
+
|
| 10 |
+
import numpy as np
|
| 11 |
+
|
| 12 |
+
from run import Invalid
|
| 13 |
+
|
| 14 |
+
_INT = re.compile(r"(0|-?[1-9][0-9]*)\Z")
|
| 15 |
+
MAX_CHARS = 200_000
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def _int(tok, lo, hi, name):
|
| 19 |
+
if not _INT.match(tok):
|
| 20 |
+
raise Invalid(f"{name}: expected an integer, got {tok[:20]!r}")
|
| 21 |
+
v = int(tok)
|
| 22 |
+
if v < lo or v > hi:
|
| 23 |
+
raise Invalid(f"{name} = {v} out of range [{lo}, {hi}]")
|
| 24 |
+
return v
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def check(inst, ans):
|
| 28 |
+
n = inst["n"]
|
| 29 |
+
s = ans.get("output")
|
| 30 |
+
if not isinstance(s, str):
|
| 31 |
+
raise Invalid("output must be a string")
|
| 32 |
+
if len(s) > MAX_CHARS or not s.isascii():
|
| 33 |
+
raise Invalid("output too long or not ASCII")
|
| 34 |
+
t = s.split()
|
| 35 |
+
if not t:
|
| 36 |
+
raise Invalid("empty output")
|
| 37 |
+
m = _int(t[0], 1, n, "m")
|
| 38 |
+
if len(t) != 1 + m:
|
| 39 |
+
raise Invalid(f"expected exactly {m} numbers after m, got {len(t) - 1}")
|
| 40 |
+
a = [_int(x, 1, n, "element") for x in t[1:]]
|
| 41 |
+
if len(set(a)) != m:
|
| 42 |
+
raise Invalid("duplicate numbers")
|
| 43 |
+
K = max(1, n.bit_length())
|
| 44 |
+
if m * (m - 1) // 2 > (1 << K):
|
| 45 |
+
raise Invalid(f"impossible: {m} elements give more pairs than the {1 << K} available XOR values")
|
| 46 |
+
if m > 1:
|
| 47 |
+
A = np.array(a, dtype=np.int64)
|
| 48 |
+
x = np.concatenate([A[i] ^ A[i + 1:] for i in range(m - 1)])
|
| 49 |
+
x.sort()
|
| 50 |
+
if (x[1:] == x[:-1]).any():
|
| 51 |
+
raise Invalid("two different pairs have the same XOR")
|
| 52 |
+
return float(m), {"m": m}
|
graders/fsh_abc_quality/check.py
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""abc-triple quality (FrontierShift fs-0375).
|
| 2 |
+
|
| 3 |
+
Answer: factorizations of a, b, c as lists of [p, e] pairs. The checker multiplies them out (exact ints),
|
| 4 |
+
requires a, b >= 1, a + b = c, gcd(a, b) = 1, each claimed prime p to pass sympy.isprime (deterministic below
|
| 5 |
+
2^64, BPSW above) and p distinct within each list. Score q = log(c) / log(R) with R the product of the distinct
|
| 6 |
+
claimed primes over a, b, c. Since every true prime of abc divides some claimed factor, R >= rad(abc) holds even if
|
| 7 |
+
a claimed "prime" were composite, so the score never overstates the true quality.
|
| 8 |
+
"""
|
| 9 |
+
import math
|
| 10 |
+
|
| 11 |
+
import sympy
|
| 12 |
+
|
| 13 |
+
from run import Invalid, int_list
|
| 14 |
+
|
| 15 |
+
MAX_DIGITS = 400
|
| 16 |
+
MAX_FACTORS = 200
|
| 17 |
+
MAX_BITS = 1330 # > log2(10^400)
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def _fac(v, name):
|
| 21 |
+
if not isinstance(v, list) or len(v) > MAX_FACTORS:
|
| 22 |
+
raise Invalid(f"{name} must be a list of at most {MAX_FACTORS} [prime, exponent] pairs")
|
| 23 |
+
val, primes = 1, []
|
| 24 |
+
for pe in v:
|
| 25 |
+
int_list(pe, 2, None, None, f"{name} factor")
|
| 26 |
+
p, e = pe
|
| 27 |
+
if p < 2 or e < 1 or e > 10000:
|
| 28 |
+
raise Invalid(f"{name}: need prime >= 2 and exponent in 1..10000")
|
| 29 |
+
if (p.bit_length() - 1) * e > MAX_BITS:
|
| 30 |
+
raise Invalid(f"{name} exceeds {MAX_DIGITS} digits")
|
| 31 |
+
if p in primes:
|
| 32 |
+
raise Invalid(f"{name}: repeated prime {p}")
|
| 33 |
+
primes.append(p)
|
| 34 |
+
val *= p ** e
|
| 35 |
+
if val >= 10 ** MAX_DIGITS:
|
| 36 |
+
raise Invalid(f"{name} exceeds {MAX_DIGITS} digits")
|
| 37 |
+
for p in primes:
|
| 38 |
+
if not sympy.isprime(p):
|
| 39 |
+
raise Invalid(f"{name}: {p} is not prime")
|
| 40 |
+
return val, primes
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def check(inst, ans):
|
| 44 |
+
a, pa = _fac(ans.get("a"), "a")
|
| 45 |
+
b, pb = _fac(ans.get("b"), "b")
|
| 46 |
+
c, pc = _fac(ans.get("c"), "c")
|
| 47 |
+
if a + b != c:
|
| 48 |
+
raise Invalid("a + b != c")
|
| 49 |
+
if math.gcd(a, b) != 1:
|
| 50 |
+
raise Invalid("a and b are not coprime")
|
| 51 |
+
R = 1
|
| 52 |
+
for p in set(pa) | set(pb) | set(pc):
|
| 53 |
+
R *= p
|
| 54 |
+
if R < 2:
|
| 55 |
+
raise Invalid("degenerate triple")
|
| 56 |
+
q = math.log(c) / math.log(R)
|
| 57 |
+
return q, {"a": str(a), "b": str(b), "c": str(c), "rad": str(R)}
|
graders/fsh_boolean_nonlinearity_9/check.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Nonlinearity of a 9-variable Boolean function (FrontierShift fs-0243).
|
| 2 |
+
|
| 3 |
+
nl(f) = 2^(n-1) - max_w |W_f(w)| / 2, W_f the Walsh-Hadamard transform of (-1)^f; exact integer arithmetic
|
| 4 |
+
(in-place fast WHT on Python ints). Score = nl(f), maximize.
|
| 5 |
+
"""
|
| 6 |
+
from run import Invalid, int_list
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
def nonlinearity(tt, n):
|
| 10 |
+
w = [1 - 2 * b for b in tt]
|
| 11 |
+
h = 1
|
| 12 |
+
while h < len(w):
|
| 13 |
+
for i in range(0, len(w), 2 * h):
|
| 14 |
+
for j in range(i, i + h):
|
| 15 |
+
x, y = w[j], w[j + h]
|
| 16 |
+
w[j], w[j + h] = x + y, x - y
|
| 17 |
+
h *= 2
|
| 18 |
+
return (1 << (n - 1)) - max(abs(v) for v in w) // 2
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def check(inst, ans):
|
| 22 |
+
n = inst["n"]
|
| 23 |
+
tt = int_list(ans.get("truth_table"), 1 << n, 0, 1, "truth_table")
|
| 24 |
+
nl = nonlinearity(tt, n)
|
| 25 |
+
return nl, {"nonlinearity": nl}
|
graders/fsh_cramer_gap_ratio/check.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Prime gap with large Cramer-Shanks-Granville ratio g / ln(p)^2 (FrontierShift fs-0377), restricted to
|
| 2 |
+
10^9 < p and p + g < 2^64 so that sympy.isprime is a deterministic (proven) primality test.
|
| 3 |
+
|
| 4 |
+
Checks: p prime, p + g prime, every integer strictly between them composite (i.e. they are consecutive primes).
|
| 5 |
+
Score = g / ln(p)^2 (maximize).
|
| 6 |
+
"""
|
| 7 |
+
import math
|
| 8 |
+
|
| 9 |
+
import sympy
|
| 10 |
+
|
| 11 |
+
from run import Invalid, as_int
|
| 12 |
+
|
| 13 |
+
LO = 10 ** 9
|
| 14 |
+
HI = 2 ** 64
|
| 15 |
+
MAX_GAP = 4000
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def check(inst, ans):
|
| 19 |
+
p = as_int(ans.get("p"), "p", LO + 1, HI - 1)
|
| 20 |
+
g = as_int(ans.get("g"), "g", 1, MAX_GAP)
|
| 21 |
+
q = p + g
|
| 22 |
+
if q >= HI:
|
| 23 |
+
raise Invalid("p + g must be below 2^64")
|
| 24 |
+
if not sympy.isprime(p):
|
| 25 |
+
raise Invalid("p is not prime")
|
| 26 |
+
if not sympy.isprime(q):
|
| 27 |
+
raise Invalid("p + g is not prime")
|
| 28 |
+
for x in range(p + 1, q):
|
| 29 |
+
if sympy.isprime(x):
|
| 30 |
+
raise Invalid(f"{x} is prime: p and p + g are not consecutive primes")
|
| 31 |
+
return g / math.log(p) ** 2, {"p": p, "g": g}
|
graders/fsh_lwc_1280/check.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Low-weight codeword in the n=1280, k=640 binary decoding-challenge code, seed 0 (FrontierShift fs-0364).
|
| 2 |
+
|
| 3 |
+
Parity check H = [I_640 | M^T]: c in F_2^1280 is a codeword iff for every j in 0..639
|
| 4 |
+
c_j + sum_i c_{640+i} * M[i][j] = 0 (mod 2).
|
| 5 |
+
Answer: the support of c (sorted, distinct indices in 0..1279, non-empty). Score = |support| (minimize).
|
| 6 |
+
Exact GF(2) arithmetic on Python ints.
|
| 7 |
+
"""
|
| 8 |
+
from run import Invalid, int_list
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
def check(inst, ans):
|
| 12 |
+
n, k = inst["n"], inst["k"]
|
| 13 |
+
sup = ans.get("support")
|
| 14 |
+
if not isinstance(sup, list) or not sup:
|
| 15 |
+
raise Invalid("support must be a non-empty list of indices")
|
| 16 |
+
int_list(sup, None, 0, n - 1, "support")
|
| 17 |
+
if len(sup) > n:
|
| 18 |
+
raise Invalid("support too long")
|
| 19 |
+
if any(sup[i] >= sup[i + 1] for i in range(len(sup) - 1)):
|
| 20 |
+
raise Invalid("support must be strictly increasing (sorted, no duplicates)")
|
| 21 |
+
rows = inst["M"]
|
| 22 |
+
syn = 0
|
| 23 |
+
for i in sup:
|
| 24 |
+
if i < n - k:
|
| 25 |
+
syn ^= 1 << i
|
| 26 |
+
else:
|
| 27 |
+
syn ^= int(rows[i - (n - k)][::-1], 2)
|
| 28 |
+
if syn != 0:
|
| 29 |
+
raise Invalid(f"not a codeword: syndrome weight {bin(syn).count('1')}")
|
| 30 |
+
return len(sup), {"weight": len(sup)}
|