Tasks in Subtasks

Hi All. I am new to Codechef. I’m a bit confused about subtasks. My solution to a problem solves the first subtask correctly. In the second subtask(Original Constraints) Out of 5 tasks for the Subtask #2 my code fails in 2 i.e I get a WA. Is there any particular approach I should start debugging with? Thanks in advance :slight_smile:

You should see the constraints and try to figure out if there is an overflow or something. As first subtask has passed and Subtask 2 hasn’t got TLE, it means your algorithm probably is correct. Just look for other things like, integer overflow

A task in a subtask is a input file that has input associated to the constraints of that subtask.

So, in general, if you are getting a Wrong Answer (WA) in a particular task in a subtask, then check you your code for that subtask, whether your code gives correct result under those constraints or not.

Some subtasks have larger constraints, that can result in data overflows, segmentation errors, or TLE depending upon the code.

1 Like

The only difference in the 2 constraints is that in the first the number of testcases are in the range 1 <= T <= 10^4 and in the second its 1<= T <= 10^6. I have used int for both as they both fall correctly in the range. I have tried debugging with some random really large test cases but all seem to work at my end.

Okay. Since my Subtask-1 has got approved and there is a WA in 2 tasks for Subtask-2 is TLE is still possible? As in, can WA mean WA as well as TLE or are they both considered separately?

If you get a WA, it means that your code ran within the time limit and gave an output that wasn’t correct. However, if you get a TLE, it means that your code took more time than the time limit to give an output, but it doesn’t mean that the output was correct. The moment your code exceeds the time limit, it is stopped by the judge immediately.