Sparse segment tree 2d

Правка en1, от 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.

Теги data structures, segment tree

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский Kener_Castillo 2026-08-08 01:10:54 76
en1 Английский Kener_Castillo 2026-08-07 08:33:09 675 Initial revision (published)