You are not logged in. Please login at www.codechef.com 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 http://www.codechef.com/viewsolution/6053749 http://www.codechef.com/viewsolution/6053833

asked 31 Jan '15, 18:07

rccroshan1's gravatar image

3★rccroshan1
735
accept rate: 0%

closed 31 Jan '15, 21:07

kunal361's gravatar image

4★kunal361
6.0k133272

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..:)

link

answered 31 Jan '15, 18:22

kunal361's gravatar image

4★kunal361
6.0k133272
accept rate: 21%

1

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

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

Thanks kunal361...next 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

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "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:

×729
×19

question asked: 31 Jan '15, 18:07

question was seen: 967 times

last updated: 31 Jan '15, 22:05