HidenoriS's blog

By HidenoriS, 6 years ago, In English,

I was working on problem D on Round 166 Div 2.

This is my submission which got TLE.

The interesting thing is that I copied the solution above and submitted exactly the same code again, and I got AC.

I submitted the TLE code multiple times, and all of them got AC.

More interestingly, my code outputted the correct solution, but I got TLE. (You can see it by comparing the output for test 8 on those two codes)

Could someone help me figure out how this happened?

Thank you.

 
 
 
 
  • Vote: I like it
  • 0
  • Vote: I do not like it

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

This two submissions were made with different selected compiler MS C++ and GNU C++. May this influenced such result.

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

    I didn't realize that so I tried it just now. I still got AC twice in a row. first and second.

    MS C++ seems slightly slower though.

»
6 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

There is a notice at the task page:
"""
Package for this problem was not updated by the problem writer or Codeforces administration after we’ve upgraded the judging servers. To adjust the time limit constraint, solution execution time will be multiplied by 2. For example, if your solution works for 400 ms on judging servers, than value 800 ms will be displayed and used to determine the verdict.
"""
Maybe your solution works near 1000ms (time may slightly vary depending on the general load of the machines), and then this time got multiplied by two, hence the time difference (850-1000ms difference looks smaller than 1700-2000ms).

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

    That makes sense. It's probably safer to optimize code as much as possible before submission in contests with that notice.