You are not logged in. Please login at to post your questions!


[closed] 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

asked 31 Jan '15, 18:07

rccroshan1's gravatar image

accept rate: 0%

closed 31 Jan '15, 21:07

kunal361's gravatar image


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

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

kunal361's gravatar image

accept rate: 21%


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

(31 Jan '15, 18:27) mediocoder3★

Thanks time i will make sure to use EOF...:)

(31 Jan '15, 22:05) rccroshan13★

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • 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:


question asked: 31 Jan '15, 18:07

question was seen: 967 times

last updated: 31 Jan '15, 22:05