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/5_Gold/PURQ.mdx
2020-06-25 00:00:28 -04:00

70 lines
No EOL
2.9 KiB
Text

---
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)
<problems-list problems={metadata.problems.sample} />
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.
<!-- <problems-list problems={metadata.problems.general} /> -->
## Wavelet Tree
<problems-list problems={metadata.problems.waveletSam} />
### Tutorial
- [CF](http://codeforces.com/blog/entry/52854)
<problems-list problems={metadata.problems.wavelet} />