Probable wrong testcases for the question TLG?


I think there are some serious issues with the testcases provided in TLG.

The input instruction says :

" The first line of the input will contain a single integer N (N ≤ 10000) indicating the number of rounds in the game. Lines 2,3,…,N+1 describe the scores of the two players in the N rounds. Line i+1 contains two integer Si and Ti, the scores of the Player 1 and 2 respectively, in round i. You may assume that 1 ≤ Si ≤ 1000 and 1 ≤ Ti ≤ 1000. "

Because of the constraints i added something like this to my code,

if(N > 10000) || if(Si < 1 || Si > 1000) || if(Ti < 1 || Ti > 1000) then Exit(0);

But the compiler kept rejecting my answer returning WA. I couldn’t understand what was going on and then after wasting a whole day’s time when i came across link text comment by @beroul i took the test case but it gave nothing as in last line score of p2 is zero.

Afterwards, just to try my luck i removed all the input constraints from my code and it works just fine. Are we not supposed to check whether an input meets the declared constraints or not? If so, what the above quote means and how a testcase that doesnot follow the instructions was given? Or maybe i am mis-understanding something. Please point it out to me.

Any answer is much appreciated. Thank you for your time. :slight_smile:

Try using assert for checking if constraints are in range or not… It will give a runtime error if inputs go out of range…

Moreover u don’t need to check if inputs are in range or not… They should be in range officially… But there can be mistake sometimes from author or tester’s side so inputs go out of range… hence it would be fine if u don’t check inputs and directly proceed to solution…
They make sure inputs are in range or not so u don’t need that… it will make ur soln slower… So avoid it…

Thank you. But a runtime error also means that my solution won’t be accepted,right?

You can ping to codechef or admin about the issue showing ur solution link… That I used assert to check inputs but it seems that there is an issue with input file… u ll be appreciated for finding a bug on codechef…

And for accepting a solution you can comment assert part… But finding a bug is more important thing than getting ur soln accepted… once they make input files correct and if they rejudge then your soln will be accepted if ur logic was correct