š WAYPOINT LESSON
The Mistake Tax
āāā advancedā³ 20 min readš Lesson 272 of 281
The four most expensive contest habits (slow I/O, re-computation, double reads, plan-not-code) and the before-submit checklist that avoids them.
The Mistake Tax
Every submission costs. A wrong-answer verdict costs a re-read, a re-compile, a re-test ā 5 to 15 minutes of contest time. Speed training is therefore mostly tax avoidance: habits that keep the first submission the right one.
The four most expensive habits
- Slow I/O. Every language has the trap. In C++: no
ios::sync_with_stdio(false)with heavycin, orendl(which flushes) in a 200000-line loop. Fast input is not an optimization; at 2Ā·10āµ lines it is the difference between 0.1s and TLE. - Re-computing inside loops. Anything invariant across iterations
(prefix sums, sorted copies, hash maps of counts) belongs before the
loop.
O(n²)pretending to beO(n). - Reading input twice. Stream positions do not rewind for free. Read once, store, process.
- Submitting the plan, not the code. The plan handles n = 1; the code crashes on it. Dry-run the code against every sample by hand before submitting: trace two variables, not the whole program.
The before-submit checklist
- Samples traced by hand ā both the given ones and one of yours
- Overflow: the largest two multiplicands multiplied, checked against 64-bit
- Boundaries: empty, single element, all-equal, maximum values
- Complexity written in a comment; it matches the constraints
- I/O format matches exactly ā one trailing space has cost medals
What the tax buys
A verified wrong solution in this module's practice set fails exactly the way a rushed submission fails. Read its verdict, name the habit that would have produced it, and the tax becomes tuition instead of loss.
ā” Now practice
Ready to CodeContest Sprints ā Four ClocksFour SELF-TIMED sprints (15/20/30/45) plus verified wrong solutions showing exactly how a rushed submission dies. Set a real timer.
4 challenges Ā· Ā· ~110 min