HeroToXero's blog

By HeroToXero, history, 7 weeks ago, In English,

i always doubt why online judges show 0 ms while running a program..even it involves some large input(like single loop of 10^8) while pc compilers take considerable time(1 second or 1/2 second, which is still 500 ms)??

also try running following code on pc compiler(it will take so much time around 5 min to show result),but on custom test of codeforces..it shows 15 ms...why??

include

using namespace std;

define ll long long

int main(){ ll i,n=1000000000000; for(i=0;i<=n;++i); cout<<i; }

 
 
 
 
  • Vote: I like it
  • -4
  • Vote: I do not like it

»
7 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

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

»
7 weeks ago, # |
  Vote: I like it +9 Vote: I do not like it

The disparity between local execution time and execution time on online judges is because of the compiler options. Among multiple other compiler switches that codeforces uses one is "O2" which enables compiler optimizations. check this link for exact details of the optimizations performed but in short for the code you have provided compiling with O2 switch completely eliminates the for loop. If you happen to understand assembly you can look here.