Question: How is WA and TLE assigned?

What I know:
Every language has a set defined time limit accordingly. If that time limit is exceeded, the code is killed and status is set as TLE.

What I want to know:
Let’s say we have a question. The answer is supposed to be of N lines.
Is a code killed as soon as it outputs the wrong answer(line)? Or is it allowed to keep running?
If, it is allowed to run even when it initially printed the wrong answer and exceeds the time limit, what would be the solution catogrized as? TLE or WA?

1 Like

Could probably test this using a quick experiment: pick a random Problem, and try submitting:

#include <iostream>

using namespace std;

int main()
{
    cout << "THIS CAN'T POSSIBLY BE THE ANSWER TO ANY QUESTION, SURELY" << endl;
    while (true)
    {
    }
}
3 Likes

Genius!

I tested it: https://www.codechef.com/viewsolution/30197924

Got TLE.

Conclusion:

Judge runs the code:
       If the code exceeds the time limit: 
             Set status as TLE
       Else if the program successfully finishes before the time limit:
             If the answer was correct:
                   Set status as AC
             else
                   Set status as WA
       Else
            /** Other Cases as Memory Segmentations, Out of bounds, etc **/
5 Likes