Better solution for 2020D?

Revision en1, by quanhoangbla, 2026-11-30 20:43:03

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$$$)

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English quanhoangbla 2026-11-30 20:43:03 541 Initial revision (published)