--- id: PURQ title: "Point Update Range Query" author: Benjamin Qi prerequisites: - Gold - Point Update Range Sum - Gold - Static Range Queries - Gold - Max Suffix Query with Insertions Only description: Range queries for any associative operation over an array with updates, using segment tree. --- import { Problem } from "../models"; export const metadata = { problems: { sample: [ new Problem("CSES", "Range Minimum Queries II", "1649", "Easy", false, ["PURQ"], ""), ], general: [ new Problem("YS", "Point Set Range Composite", "point_set_range_composite", "Easy", false, ["PURQ"], ""), new Problem("Gold", "Springboards", "995", "Normal", false, ["PURQ"], ""), new Problem("Plat", "Nocross", "721", "Normal", false, ["PURQ"], ""), new Problem("CSES", "Hotel Queries", "1143", "Normal", false, ["PURQ"], ""), new Problem("CSES", "Subarray Sum Queries", "1190", "Normal", false, ["PURQ"], ""), ], waveletSam: [ new Problem("YS", "Range K-th Smallest", "range_kth_smallest", "Hard", false, ["Wavelet"], ""), ], wavelet: [ new Problem("Kattis", "Easy Query", "easyquery", "Hard", false, ["Wavelet"], ""), new Problem("DMOJ", "Ninjaclasher's Wrath 2", "globexcup19s4", "Hard", false, ["Wavelet"], ""), ], } }; - Normal SegTree - [USACO Old Gold Seating](http://www.usaco.org/index.php?page=viewproblem2&cpid=231) (check ...) - [USACO Old Gold Optimal Milking](http://www.usaco.org/index.php?page=viewproblem2&cpid=365) (check ...) - [USACO Old Gold Marathon](http://www.usaco.org/index.php?page=viewproblem2&cpid=495) (check ...) - [USACO Plat Balancing](http://www.usaco.org/index.php?page=viewproblem2&cpid=624) (check ...) - [POI Cards](https://szkopul.edu.pl/problemset/problem/qpsk3ygf8MU7D_1Es0oc_xd8/site/?key=statement) [](81) A **segment tree** allows you to do point update and range query in $O(\log N)$ time each for any associative operation. Historically, no gold problem has required the use of a segment tree in place of a binary indexed tree, but it's still good to know (and you might find it simpler). ### Tutorials - CPH 9.3 (Segment Trees) - [PAPS 11.2.3](https://www.csc.kth.se/~jsannemo/slask/main.pdf) - [Codeforces Tutorial](http://codeforces.com/blog/entry/18051) - [CSAcademy Tutorial](https://csacademy.com/lesson/segment_trees/) - [cp-algorithms](https://cp-algorithms.com/data_structures/segment_tree.html) - [Slides from CPC.3](https://github.com/SuprDewd/T-414-AFLV/tree/master/03_data_structures) ### Problems Can try solving some of the BIT questions w/ segtree. ## Wavelet Tree ### Tutorial - [CF](http://codeforces.com/blog/entry/52854)