This repository has been archived on 2022-06-22. You can view files and clone it, but cannot push or open issues or pull requests.
usaco-guide/content/6_Plat/2DRQ.md
Benjamin Qi 84cc6bcebd + PAPS
2020-06-22 21:00:35 -04:00

3.3 KiB

id title author prerequisites description
2DRQ 2D Range Queries Benjamin Qi
Platinum - Range Update Range Query
Extending Range Queries to 2D (and beyond).

See my implementations.

Static Array Queries

2D BIT

Tutorials

  • GFG 2D BIT
  • TopCoder BIT
  • Suppose that you want to update N\approx 10^5 points with both coordinates in the range [1,N].
    • The 2D BITs mentioned above use O(N^2) memory, which is too much.
    • Can be reduced to O(N\log^2N) memory with unordered map, but this might also be too much (and too slow).
    • If you know the points to be updated beforehand then you can reduce to O(N\log N) memory (and no maps).

You can extend the 1D BIT solution for range update range query to higher dimensions as well

  • Paper
  • USACO Camp - "Cows Play Global Thermonuclear War" (2D case)

Problems

2D Segment Tree

Note: no lazy propagation in 2D.

Short Description

  • CSES 28.2 (Sparse Segment Tree), 28.4
  • Segment Tree (or BIT) nested inside segment tree
  • use 2D offline BIT instead whenever possible (faster, lower memory)

Problems