tosivanmak's blog

By tosivanmak, history, 4 months ago, In English

I came up with a quite slow solution for Educational Codeforces Round 168 Problem F at the last minute of the contest, and I was unable to implement it on time.

When I tried implementing the solution after the contest, it showed a time limit exceeded verdict on codeforces. 273604133

However, when I test the exact same code and same test on atcoder with the "Custom invocation", it shows that the code only runs in 2155 ms, which is much lower than that of the TL. Can anyone help me with this issue? Thanks.

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

»
4 months ago, # |
  Vote: I like it 0 Vote: I do not like it

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

»
4 months ago, # |
  Vote: I like it 0 Vote: I do not like it

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

»
4 months ago, # |
  Vote: I like it +8 Vote: I do not like it

It's probably because of abuse of long long. I did some optimizations and it fits in time limit. See 273863548. The wrong answer verdict is not my issue.

  • »
    »
    4 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Will long long really slow down programs?

    It seems that many people have mentioned it. But why?

    • »
      »
      »
      4 months ago, # ^ |
        Vote: I like it +8 Vote: I do not like it

      long long uses more memory which makes it slower. I am not sure if long long will affect the speed of modulo though.

      • »
        »
        »
        »
        4 months ago, # ^ |
          Vote: I like it +19 Vote: I do not like it

        My solution now passes the task. I will be more careful when using long long in the future. Thanks for your help.

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

If the problem can be reproduced, perhaps CF's judger is really slower.

Perhaps you can check the processor models of CF and Atcoder.

Also, I heard that CF is Windows and Atcoder is Linux, but I'm not sure if there's a difference.

Hoping This Helps.

  • »
    »
    4 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Then I think cf is probably much slower than that of atcoder, probably need to be more careful with constants when doing cf problems in the future.