shamir0xe's blog

By shamir0xe, 6 years ago, In English,

in the past Codeforces Round #203, I submitted my solution for C-Bombs with MS C++ compiler and it gave me TLE, and after that I submitted the completely same code with the GNU C++ and it was accepted!! Is it the accident or it could happen in the future again? If choosing the MS C++ compiler can turn the correct solution into TLE in the final testing phase, is it reasonable that we submit our code with it? :S

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

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

You shouldn't use std::endl, when you have no need in it, because it flushes stream and as result there is no buffering. Use "\n" instead of std::endl. Your code 4651955 passed system tests without it. More about flushing stackoverflow

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

    and GNU C++ have handled it with better idea?

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

      No, you can see that 4652045 on GNU C++ passed tests with maximal 312 ms, and it more than twice faster than your with std::endl, I suppose the actual reason is ios_base::sync_with_stdio(false) doesnt improve speed in MS C++, see 4652068 without this line. And also std::sort is realized in different ways and it could be also the reason.

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

        woww... it's very interesting... thanks a lot man ;)