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

Автор Dannypa, история, 3 года назад, По-английски

Hello, codeforces!

In the last contest, Technocup 2022 - Elimination Round 1, there was a problem 1583D - Omkar and the Meaning of Life. I tried to solve it, but got TLE on test 2. Here is my submission: 132282353. The strange thing is that when I tried to test it locally, it worked fast. I counted the time it took for my program to finish (without input: I surrounded each input with block like that:

            int current_time = clock();
            total += (current_time - start_time);
            cin >> k;
            start_time = clock();

), and turned out it took only 16 ms. So, I have a question: why could it be, that the code work without tle on my machine and get TLE on cf server?

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

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

If you run your program on test case 2 ($$$[3,5,4,2,6,1]$$$), your program will eventually print the line ? 1 1 1 1 1 7 which violates the constraint $$$1 \leq a_i \leq n$$$. I have no idea why the interactor stops and gives you TLE (maybe it should have given $$$-1$$$ for invalid input).

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

    wow thank you so much, that explains everything

    very sad though, may be I would have been able to figure out what's wrong during the contest..