Today, while I'm trying to solve this easy problem 404A - Valera and X,
I write this code 11264735 using
ios_base::sync_with_stdio(0); and I got a wrong answer on test 2, but when I removed them from my code 11264741 I got Accepted, why??
You can't use printf/scanf once you write
Can you explain, please :)
printf. This is fine and will result in a speedup if you just use
cout, but if you mix that with stdio-style IO, then weird things happen. For example if the input is 5 6 and your code says
You might get a=6, b=5 or something like that. Similarly,
might result in "NOYES" instead of "YESNO". At least that's my understanding of it.
Thanks a lot. :)
what is the use of cin.tie(0) ?
It seems that by default, cout is flushed before each input operation on cin:
cin.tie(0) turns this off by instead "tying" cin to nothing.
Presumably this is done for performance reasons. It would make a significant difference in programs that interweave numerous cin/cout calls, such as those that answer a large number of queries from the input in an online manner.