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

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

I had solved this problem.Time limit of this problem is 1 sec.After complete of my all calculation I had run a big nested loop and submit that.Then I had surprised!!!I got AC and the execution time of that code as same as my real code. How it is possible??? Why I didn't get TLE?? Why the execution time as same as my real code??

Please anyone help me............

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

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

Probably the compiler optimises away the loop because it detects that you are not actually doing any work inside that loop.

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

The compiler is optimizing your code. Check this submission:

http://mirror.codeforces.com/contest/486/submission/29111856

So, yes, the compiler is optimizing the mega big loop.

This is your code with only one change: now all variables are volatile. If a variable is volatile then the compiler won't optimize any code which involves this variable. This is useful on bigger programs where you are certain that compiler optimizations may not take into account things like external acceses and similar things.