34. Judge profiles (§9, 0.2.2, 2026-11-21)
- 34.1 A judge is a profile, in its own crate.
crates/cpl-judgeholds the profile type, the built-ins (generic,codeforces,atcoder,cses,icpc,kattis,dmoj) and their selection. It depends on nothing, so the CLI, the wasm playground and the stress tools can share it; codegen takes only acpl_codegen::Target(a header stamp and whether the judge's stack is deep), so it knows no judge by name. Reverse: fold the crate intocpl-cliand pass the limit alone.
- 34.2 The flag beats the file, which beats the project, which beats
generic.--judge, then a// judge:line (like// limits:), thenjudge = "<name>"under[judge]in the nearestcp.toml.[judge.<name>]tables change a built-in's fields or add one withextends, so a course's judge needs no code. Unknown names and keys are errors listing what is allowed. Reverse: drop a source fromcpl_judge::resolve.
- 34.3 The default stays
generic, the old behaviour.g++ -std=c++17 -O2, an 8 MB stack and 64 KB: the floor most judges clear, so a file built with no profile is what 0.2.1 wrote plus one header line. Reverse: change theNonearm ofresolve.
- 34.4 A profile records the judge's real command and says where each fact comes from. Flags are
copied from the judge's published command (AtCoder's library and link flags left out); a fact that could
not be read from a public source is marked unconfirmed in
evidence, shown bycpl judges(the Codeforces page sits behind a browser check). Reverse: none needed; correct a fact when a source says so.
- 34.5 (replaced by 31.4: every program runs on a thread with the profile's stack) Deep recursion skips its own stack only when the judge's stack is known to be deep. At least
256 MB or unlimited (
codeforceslinks with a 256 MB stack, DOMjudge's runguard sets it unlimited); an undocumented stack counts as 8 MB. The switch is harmless where it is not needed, so the error is on the safe side. Reverse:Profile::deep_stackreturningfalse.
- 34.6 The source limit is the profile's, with a warning above 75%. The 48 KB warning of goal 5 for a
64 KB judge, scaled. The size line names the judge and the share used. Reverse:
Profile::warn_at.
- 34.7 Locally, a judge's flags are used as far as the compiler here accepts them. Each profile's
command is probed once (an empty program built with
-Werror); a rejected flag is dropped or given the older spelling of the same standard, and reported. A flag and its value (-x c++) and a--whole-archivespan are probed as one. A Windows profile builds with a MinGW cross compiler when one is installed. This tests what the judge's flags mean for the generated code without the judge's exact compiler version; containers with those versions remain open. Reverse: probe nothing and require every flag.
- 34.8 Every port under every profile's flags is a
--fullcheck. 1,799 compiles take about two and a half minutes on eight cores, too slow for--fast;--fastbuilds every port for every profile (size, stamp, stack rule) and compiles and runs the deep-recursion program under each. Reverse: move the ignored test into--fast.
- 34.9 Local runs build a
.cpfile for its judge and run it on the judge's stack.run --release,test,stressandhuntresolve the file's profile, emit for it, build with its flags as the host g++ accepts them (the host compiler for a Windows judge) and wrap the binary insh -c 'ulimit -s N'when N differs from the current limit; a stack the shell can't grant fails with exit 125 and names the judge. Goal 5 says local runs mimic the profile, and the stack is where they differed most (a recursion that fits 8 MB here could overflow a judge, and the reverse). Theg++ -std=c++17 -O2build keeps its precompiled header; other flag sets build without it. Reverse:build_judgedback tocompile_cpp(&emit_cpp(..)).
- 34.10 The size report is measured on the file, by the code generator's own parts. The emitter keeps
the text of each part it writes (the header, each runtime piece, the types, the globals, each fn, the
top-level code), the report measures it as the file has it (narrowed when the file is) and calls the rest
glue, so the parts add up to the file by construction. A fn is named as its source names it (
Rooted.path), its instances summed. Shown on--sizeand on every build over the limit, the one time it is needed. Reverse: dropEmitter::chunksandcpl_codegen::sizes.
- 34.11
cpl profile --nativebuilds for the file's judge. It resolves the profile likecpl build, writes the counted C++ for that target (its thread stack, its OS's threads), builds with the judge's flags this compiler accepts and runs on the judge's stack, the sameProfile::on_stackcommand the stress runner uses; a profile timed on another build can rank the lines differently.CXXstill overrides the compiler. Reverse:emit_profiledwithout a target andg++ -std=c++17 -O2.
- 34.12
cpl testgives MLE past the problem's memory limit. A case whose sampled peak memory (VmHWM, asbenchreads it) is over the limit isMLEwhatever it printed, as a judge stops it there; a time limit outranks it. Sampling can miss a peak in the last 0.3 ms of a run, so an MLE is certain and anokis not proof. Reverse: dropVerdict::MemoryLimitand the check inrun_cases.
- 34.13 The comments on the C++ give way first, before the source in the header. A file over its
judge's limit loses, in order, its comment lines (all but the header at the top; a comment after code
stays), then the source in the header, then half its indentation. The contestant's own source says more
on the judge's page than the generator's notes on its runtime, and both cost the same to the judge.
Fitted::notesays what was left out, for the CLI and the playground alike. Reverse: drop theuncommentedrung inemit_within_for.
- 34.14
cpl submitiscpl buildthencpl test, and sends nothing. It takes no--judge: the file or project names its judge, so the build and the cases cannot disagree on one. No cases is a warning, not a failure, since many problems are tried before their samples are saved. It sends nothing because no judge we target offers a submission API it allows scripts to use, and a scraped login is a credential in a tool that must not hold one. Reverse: dropsubmitfromcpl-cli.