Codeforces Round 1133 (Div. 1, Div. 2) is coming soon! Register here. ×

TooDumbToWin's blog

By TooDumbToWin, history, 10 years ago, In English

I ran these codes in custom invocation and got weird running times.


#include<bits/stdc++.h> using namespace std; int main(){ //Hi for(int i=0;i<5000000;i++)cout<<i<<" "; return 0; }

Run time: 2448 ms


#include<bits/stdc++.h> using namespace std; int main(){ for(int i=0;i<5000000;i++)cout<<i<<" "; return 0; }

Run time: 2901 ms

Can anyone explain why adding comment is having significant impact on running times?

PS: Changing comment affected run time slightly as well.

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

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

I guess it should just be difference between each runs. And codeforces caches your submission so if you submit one multiple times, it will return the same result.

  • »
    »
    10 years ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    "I guess it should just be difference between each runs." I didn't get you. Can you please rephrase the statement?

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

      Due to dynamic CPU frequency, server load or some other reasons, time required for processing the same data by identical program may varies. As a result, several runs of a program may result different time consumed.

      Sorry for my bad English, hope this makes more sense.

  • »
    »
    10 years ago, hide # ^ |
     
    Vote: I like it +23 Vote: I do not like it

    Online judge should not be so unstable that time difference between runs of the same program is over 400 ms.

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

Tried it 8 times. If I change the comment for "Petr" it works.

  • »
    »
    10 years ago, hide # ^ |
     
    Vote: I like it +8 Vote: I do not like it

    CodeForces doesn't recompile your code if it's the same (at least in some time window)

    so tried 8 times may mean that result just was cached