This code is working perfectly in IDE but giving wrong answer on submitting. Why?
https://ide.codingblocks.com/s/54293
Delhi's odd-even problem
The code is producing a wrong output because you have initialized flag and car =0 only once , rather you have to do it for every testcase .
Hence Put these lines inside the first while loop and submit the code.
while (t>0)
flag = 0;
car = 0;
Got it but then why did it work fine when i did it in the ide?
Hey Divyam, that’s just a matter of chance because may be for that particular case your code was satisfying the conditions, but it is not general.