Competitive programming
Judge Verdicts Explained: AC, WA, TLE, MLE, RE and CE
An online judge compiles your program, runs it on test inputs, and compares the output with the expected answer. The verdict tells you which step went wrong. Each one points at a different kind of bug, so reading it correctly saves a lot of guessing.
The six verdicts at a glance
| Verdict | Meaning | First thing to check |
|---|---|---|
| AC — Accepted | Output matched on this test | Nothing; try edge cases next |
| WA — Wrong Answer | The program ran, but the output differs | Edge cases, overflow, output format |
| TLE — Time Limit Exceeded | The program ran too long | Algorithm complexity, slow input/output |
| MLE — Memory Limit Exceeded | The program used too much memory | Array sizes, recursion, data structures |
| RE — Runtime Error | The program crashed or exited with an error | Index out of range, null, division by zero |
| CE — Compile Error | The code didn't compile | Syntax, wrong language version, missing import |
Wrong Answer: the most common, and the most varied
- Edge cases: the smallest input (n = 0 or 1), the largest, all-equal values, negative numbers.
- Integer overflow: a sum of many values up to 10⁹ needs 64-bit integers (
long longin C++,longin Java). - Output format: missing newlines, extra spaces, "YES" versus "Yes", or too few decimal places.
- Reading input wrong: several test cases in one input, or lines with trailing spaces.
- Uninitialised variables, or state left over between test cases.
Compare your output with the expected one character by character. A side-by-side view finds a trailing space or a missing line in seconds.
Time Limit Exceeded
A rough rule: about 10⁸ simple operations take a second. Compare that with your algorithm's complexity at the largest input. With n = 10⁵, an O(n²) loop does 10¹⁰ steps, far too many, while O(n log n) does under 2 × 10⁶.
- Replace nested loops with sorting, two pointers, prefix sums or a hash map.
- Speed up input and output: in C++ add
std::ios::sync_with_stdio(false); std::cin.tie(nullptr);, in Python read all input at once withsys.stdin.read(). - Check for an infinite loop: a TLE on a tiny input is almost always one.
Memory Limit Exceeded and Runtime Error
- MLE: a 2D array of 10⁴ × 10⁴ integers is 400 MB. Store only what you need, or reuse rows.
- Deep recursion uses stack memory; convert it to a loop, or raise Python's recursion limit with care.
- RE: the usual causes are reading past the end of an array, dividing by zero, dereferencing a null pointer, and an uncaught exception.
- In Python, a RE often comes from parsing input that isn't shaped the way you expected.
Compile Error
The compiler's message names the line and the problem. Check that you picked the right language and version: C++17 features don't exist in C++11, and Python 3 code doesn't run as Python 2. Java judges usually expect the class with main to be named in a particular way.
Getting verdicts on your phone
omni compiler runs your code in 65 languages and judges every test case you add, with up to 100 tests per run. Each test gets its own verdict with timing, and a wrong answer shows your output beside the expected one. Compile errors can be tapped to jump to the line.
Next, learn how to write test cases that catch bugs.