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

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

During Yesterday's EDU round, My solution to D was accepted and during system testing, it got TLE on test case 60. AC during contest : (https://mirror.codeforces.com/contest/1499/submission/110354551)

Now I submitted the same code multiple times after system testing is over, it is getting accepted. AC after system testing : https://mirror.codeforces.com/contest/1499/submission/110419651

So can anyone please tell what can be wrong in this scenario ?

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

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

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

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

same with my submissions....

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

Yes, I am having similar issues. All submissions are almost the same, you can compare. I think that the time limit to this problem is not optimal.

Submission 1 : https://mirror.codeforces.com/contest/1499/submission/110420452

Submission 2 : https://mirror.codeforces.com/contest/1499/submission/110390562

PS: the same code Submission : https://mirror.codeforces.com/contest/1499/submission/110420816 gives tle on test 39 now.

PS (yet again) : The SAME CODE is $$$Accepted$$$ now!!! Solution : https://mirror.codeforces.com/contest/1499/submission/110421153

Just change the way you write $$$2\times 10^7$$$, you will get tle. Solution : https://mirror.codeforces.com/contest/1499/submission/110422095

I have made some minor changes in each submission, so that Codeforces allows me to resubmit.

Admins please look into this issue, to either increase the time limit of this problem or take some other steps you might find suitable in this case.

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

    To all the people that passed with 1996ms, you just got extremely lucky, nothing more than that. Your solutions should have failed. Extra log factor adds 500ms to the execution time in this case, and that ruins the purpose of this problem, it's a D2D, all the details matter. If you really want to make it fair — than take the time limit down to 1.9s, and the lucky ones will get removed. There are dozen of non-optimal implementations which will pass if you increase TL from 2 to 2.2-2.3 seconds. Come on, it's just one contest, don't blame tests for your mistakes.

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

I don't know the specifics of why it happened, but I think it's something to do with a bit of random variance when running a program.

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

Yep, that happens, its just that every time you run a program it won't run in exactly the same time, there will always be minor fluctuations in runtime, for example this submission ran in around 1980 ms during the contest but I figured it would probably TLE out in system test so I optimised it a bit and submitted it again here which ran in around 1700ms during the contest, It barely passed on system test with 1996ms :/

So yeah, optimise as much as you can.

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

    there are many people who got accepted and have 1950ms or above time limit during contest.

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

      Yes, as I said runtime fluctuates by a bit, so for a program that should take 1000ms, sometimes it may take 1050ms and sometimes it may also run in 950ms, as a result some people's solution might TLE out while some of those solution may also pass due to those minor fluctuation even though they had roughly the same runtime during the contest, as such we can't really do much about this and therefore our best option is to just optimize as best as we can.

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

    Yeah my solution also ran in 1996 ms

    But Why do we have such random run time despite having a same time complexity and same constant factor(i guess)?

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

      The truth is you don't. If you remove vis array from solution. You get 1600ms runtime, it's your fault, it's not needed. Were you able to estimate 2e7 log 2e7 takes about 0.5s to execute => your solution is nowhere near optimal, because you do useless calculations. Come on, it's a D2D, what do you expect, writing a 0.5s random for loop and expecting to pass? 110425446

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

same issue with me
tle:110372505
now passed: 110421066

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

Same issue TLE: 110405479 AC: 110422060

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

I think sometimes if the time limit is so strict they should rejudge the solutions by increasing the time limit by small amount

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

No need to rejudge, there was more than enough time for solutions to pass. It's your fault choosing to use unoptimal strategies. Simplest sieve passes all the tests in about ~1.3s. Take a look at icecuber's submission and you'll see what I'm talking about. It's the same as saying, please increase the time limit I used map instead of unordered_map.

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

    Your factorization is not optimal — therefore you waste ~500ms. It can be all done in one for loop, no need for another log factor. You add n log n execution time in the worst case, which is ~2e8 operations, these solutions should be intended to fail, when you add such a large factor for no reason.

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

I was able to get the runtime close to 1000 ms with some precomputation with sieves. Can anyone help optimize this any further? I would be very grateful

https://mirror.codeforces.com/contest/1499/submission/110425912

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

Same thing happened with me.see this 110380490 and this 110426784.MikeMirzayanov sir these submissions are same.still one passing after sys test and another giving tle during sys test