Please read the new rule regarding the restriction on the use of AI tools. ×

FullMetalChains's blog

By FullMetalChains, history, 13 months ago, In English

Here are two solutions to problem D of today's contest

1.First solution

My Code
  1. Second solution
His Code

The first one shows TLE on testcase 8 while the second one shows accepted. Both are same solutions to the problem.

Does anyone know why the results are so different?

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

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

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

»
13 months ago, # |
Rev. 3   Vote: I like it +28 Vote: I do not like it

Fast IO

Add this line to the beginning of your code and it will pass the tests:

cin.tie(0) -> sync_with_stdio(0);
Explanation:
  • »
    »
    13 months ago, # ^ |
      Vote: I like it +8 Vote: I do not like it

    This is so unfortunate. I resubmitted the answer I had during the contest(It gave TLE at that time) and now, it passed now. I feel robbed :(

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

    I also noticed that FullMetalChains uses endl in submissions. For a similar reason, you should try using '\n' instead for non-interactive problems so it avoids flushing.

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

      I always add #define endl '\n', I find it easier to just comment it out on interactive problems. (If you are used to writing endl like me, you might consider doing this as well)

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

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