TLE using getchar_unlocked()

Its the second time for me that the use of getchar_unlocked() resulted in a TLE and the same solution gave AC on changing from gc() to scanf(). Can anyone expalin the reason. The solutions are
http://www.codechef.com/viewsolution/6053749
http://www.codechef.com/viewsolution/6053833

Have a look at these 2 codes: TLE, Success

The error in your code is the while loop…for the last test case in a test file…the last char is an EOF char and not a ‘\n’…which leads to an infinite loop…hope this helps…:slight_smile:

2 Likes

Nice, thanks. Now I know how to take input till EOF.

1 Like

Thanks kunal361…next time i will make sure to use EOF…:slight_smile: