×

# [closed] TLE using getchar_unlocked()

 0 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 asked 31 Jan '15, 18:07 73●5 accept rate: 0% 4★kunal361 6.0k●13●32●72

### The question has been closed for the following reason "The question is answered, right answer was accepted" by kunal361 31 Jan '15, 21:07

 2 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..:) answered 31 Jan '15, 18:22 4★kunal361 6.0k●13●32●72 accept rate: 21% 1 Nice, thanks. Now I know how to take input till EOF. (31 Jan '15, 18:27) Thanks kunal361...next time i will make sure to use EOF...:) (31 Jan '15, 22:05)

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×729
×19

question asked: 31 Jan '15, 18:07

question was seen: 967 times

last updated: 31 Jan '15, 22:05