Sparse segment tree 2d

Revision en1, by Kener_Castillo, 2026-08-07 08:33:09

So I wanted to see if it was possible to solve this problem 160-E with a sparse segment tree 2D. I made this implementation (because I didn't find any) 386015499. Unfortunately, it passes in approx 1200 ms and 80 MB (the best it did was 1031 ms with iterative queries).

Anyways, I'm sharing the implementation 386021321 (slower but more general) in case anyone finds it useful, it allows queries and point updates in $$$O(log^2 n)$$$ with the preprocessing of all the intervals in $$$O(n \ log \ n)$$$. It is possible to make some optimizations but it should pass under 2 seconds.

Tags data structures, segment tree

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English Kener_Castillo 2026-08-08 01:10:54 76
en1 English Kener_Castillo 2026-08-07 08:33:09 675 Initial revision (published)