Please subscribe to the official Codeforces channel in Telegram via the link https://t.me/codeforces_official. ×

Hyperlink_Blocked's blog

By Hyperlink_Blocked, history, 5 years ago, In English

I was wondering why the exact same code

https://codeforces.com/contest/833/submission/53432006

gets a TLE on test 8 when submitted in C11 but

https://codeforces.com/contest/833/submission/53431981

gets AC when submitted in G++14. Does the C++ compiler optimize the operations or something? If I'm not wrong the complexity of this solution should be O(n log max(a*b)) (I assumed the complexity of cuberoot is log n, I don't actually know what it is).

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

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

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

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

It's most likely a problem with I/O. I used custom invocation to output INT_MAX 300000 times (the number used in the failing test case). The code remained the same for both tries. I used printf. The results:

  • C11: 1045 ms

  • C++14: 93 ms

»
3 years ago, # |
  Vote: I like it 0 Vote: I do not like it

hahaha that was funny ! : )) I have never senn that : ||