vidit_jain's blog

By vidit_jain, history, 7 years ago, In English

Hi, I tried to hack a solution of problem A of div2 of round 424 (Based on VK Cup final). In that solution there is an extra 'cin'(in line 4th in int main) in the code which is wrong if n=1 and I think it has to show TLE in that case. I tried test case as follows 1 7 which outputs YES in original case but in that I think the compiler has to wait for another input y but my hack got unsuccessful. Don't know the reason. Can somebody please tell me whats wrong in it? Attached is the link to the code I tried to hack : http://codeforces.com/contest/831/submission/28514528

Thanks :)

  • Vote: I like it
  • +2
  • Vote: I do not like it

| Write comment?
»
7 years ago, # |
  Vote: I like it +5 Vote: I do not like it

Your hack was not successful because cin doesn't "wait" for input when it has reached EOF. EOF is end of file. So in case cin has reached EOF, it just appends nothing to the input. And the variable contains some garbage value, which it had when declared.

For more information: https://softwareengineering.stackexchange.com/questions/259974/is-checking-for-cin-eof-really-necessary/259985