quanhoangbla's blog

By quanhoangbla, history, 28 hours ago, In English

As you know I've just solved 2020D with a solution I came up with that's more readable and probably more efficient than the one in the editorial.

So, for each step size max_d (or just fix it at 10), remember how far each operation connects. Then merge intervals with some simple greedy then use DSU to find number of connected opponents

Anyways here's my code 400436229

The solution runs in $$$O(M+10\times N\times \alpha (N))$$$ Where $$$\alpha$$$ is the inverse Ackermann function (3-4 for $$$N=10^6$$$)

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

»
13 hours ago, hide # |
← Rev. 2  
Vote: I like it +10 Vote: I do not like it

I was able to find a solution with $$$O(M + 10N)$$$ time complexity.

I bucketed the operations by start point, then merged overlapping intervals with the same $$$d_i$$$ and $$$a_i \bmod d_i$$$. From there, process $$$d$$$ from 1 to 10. If a position is inside an interval of a divisor of $$$d$$$, you add an edge and go past it since every point in between is already covered. Else, claim the point or link to the interval that claimed it first.

  • »
    »
    8 hours ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it