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

Автор Vicennial, история, 8 лет назад, По-английски

86D - Мощный массив

I tried implementing Mo's Algorithm to solve this problem but I ran into a couple of TLE's when taking block size as sqrt(Max N) which is 448.
The submission can be viewed here-21756475 The result was TLE when using block size=448.
In the next submission-21756591 , I put block size=1000 and the result was AC.

So my question is how do I figure out what value to use as my block size?

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

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

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

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

Assuming you do not want to submit a large number of times with different block sizes, one way to do this is by creating a test case with the highest possible values for n and t (and randomly generated queries) and testing the runtimes for different block sizes.

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

I submitted different forms of my code for around 20 times in this question. What I saw is that time taken in this question changes abruptly even on subtle changes in code.

For example I changed ll to int in your code for some arrays and numbers except answer ones http://codeforces.net/contest/86/submission/24079499 and it got AC.

When I was doing it, I removed #include <bits/stdc++.h> from my code and time reduced to 2240 from 3630 ms. I think it takes pretty neat and to the point code at Codeforces otherwise these things shouldn't matter.