I wrote two different codes, which differs only on order of headers. Two codes are like these:
#include <stdio.h>
#include <algorithm>
....(blahblah)....
2.
#include <algorithm>
#include <stdio.h>
....(blahblah)....
Note: At (blahblah) part, there are 9 millions scanf("%d", &t) operations. Compilation options are both GNU C++14. (GNU C++14 6.2.0, which is used on Codeforces.)
For my opinion, this two code should exactly do the same operations.
But, 1st code gives 1.6ms / 2ms AC, and 2nd code gives TLE. This issue is not about server status, it's still same during many submits.
Can someone help me about what's going on here?
Note : It's not 1.6ms / 2ms, It's 1.6s / 2s
Auto comment: topic has been updated by dotorya (previous revision, new revision, compare).
For full code, here are submission links:
http://codeforces.net/gym/100960/submission/26124378 http://codeforces.net/gym/100960/submission/26124363
What happens if you use c++11?
I submitted same code with c++11, and it both got AC in 1.5ms / 2ms.
http://codeforces.net/gym/100960/submission/26124656 http://codeforces.net/gym/100960/submission/26124661
http://codeforces.net/blog/entry/47180
This is what i was finding. Thanks!
c++14 scanf problem
It seems that using scanf in <stdio.h> is much faster than others in c++14. I think if you include algorithm first will let you use the scanf that is in the algorithm but not in the stdio.h one? (just a random guess tho)
Auto comment: topic has been updated by dotorya (previous revision, new revision, compare).