theRevenant's blog

By theRevenant, history, 10 years ago, In English

My team ranked 107 on snackdown el. round and we just missed the onsites with a time diff of <20 mins. However i checked one of my WA on the easiest question and i noticed this. Problem Link : www.codechef.com/problems/TTENIS

Code which gave WA during contest : http://www.codechef.com/viewsolution/7190656 Code which gave AC after contest : http://www.codechef.com/viewsolution/7248112 The only difference between these two codes is that "scanf("%d", &t);" is replaced by "cin>>t;"

Also another query , if someone can read the question and tell me why this logic fails: http://www.codechef.com/viewsolution/7191333 The logic is based on the fact that this is given in the question :- "(It is guaranteed that statistics always represent a valid , finished match.)"

Any help will be grateful. Thnx a lot :)

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

»
10 years ago, # |
  Vote: I like it +5 Vote: I do not like it

Looks like you are using ios::sync_with_stdio(0); in the first case. In that case you are using both the scanf and cout. But you should not use scanf/printf with the syncing off as it may result in unexpected interleaved characters as explained in this post :- http://mirror.codeforces.com/blog/entry/6251?#comment-235617. So maybe that was the reason for you WA in first answer whereas AC in second answer when you switched back to cin/cout.

And in the second query the logic fails because it may happen that the game ended a long time ago but extra statistics were given. So early in the game chef wins the game but due to extra statistics it may seem that his friend won. Also here again you are using scanf with sync_with_stdio(0) which may be causing the error. Try using cin in this case and resubmit your answer. If it passes all cases then your logic was correct otherwise the fault in your logic maybe as i explained earlier.

Hope it helped.