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

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:


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: