Verification Before Submission
The adversarial checklist that catches most bugs before the judge does.
Verification Before Submission
A submission is an experiment; run the experiment yourself first. The checklist below catches the majority of wrong answers in practice:
The tiny-n pass
Trace your algorithm by hand on n = 1, n = 2, n = 3. Most loop-bound and off-by-one bugs live here, and hand-tracing takes seconds. If the code branches on n, test both branches.
The degenerate pass
- all values equal (hits tie-handling, duplicate logic);
- all values distinct already (hits "already satisfied" paths);
- sorted ascending and sorted descending (hits monotonicity assumptions and two-pointer directions);
- extremes: minimum and maximum allowed values, including negatives.
The direction pass
For graph problems: does the edge direction match the statement? For string problems: prefix vs suffix confusion? For ranges: inclusive vs exclusive ends? These three are the most common silent misreads.
The overflow pass
Count the bits. Sum of n values ⤠10^9 each overflows int32 at n ā 2 ā long long from the start is cheaper than one WA. Products: n(nā1)/2 with n = 10^5 is ~5Ā·10^9, long long territory. A comparator that subtracts integers can overflow ā compare, don't subtract, unless you know the range.
The complexity pass
Multiply out the loops at max constraints. nĀ·q with both 2Ā·10^5 is 4Ā·10^10 ā dead. n log n with log = 18 is 3.6Ā·10^6 per op-set ā comfortable. If the estimate is near the ceiling (~10^8ā3Ā·10^8), reduce constants before coding: faster I/O, fewer modulo operations, flattened loops.
The read-back pass
Re-read the statement after coding. Output format (trailing newline? spaces?), multiple test cases per file, "if impossible print ā1" clauses ā the requirements your code can satisfy while failing the check anyway.