Блог пользователя dotorya

Автор dotorya, история, 7 лет назад, По-английски

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

  • Проголосовать: нравится
  • +71
  • Проголосовать: не нравится

»
7 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by dotorya (previous revision, new revision, compare).

»
7 лет назад, # |
  Проголосовать: нравится +19 Проголосовать: не нравится

What happens if you use c++11?

»
7 лет назад, # |
Rev. 3   Проголосовать: нравится +10 Проголосовать: не нравится

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)

»
7 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by dotorya (previous revision, new revision, compare).