88 lines
2.7 KiB
Text
88 lines
2.7 KiB
Text
---
|
|
id: RURQ
|
|
title: "Range Update Range Query"
|
|
author: Benjamin Qi
|
|
prerequisites:
|
|
- Gold - Point Update Range Query
|
|
description: Lazy updates on segment trees and two binary indexed trees in conjunction.
|
|
frequency: 1
|
|
---
|
|
|
|
import { Problem } from "../models";
|
|
|
|
export const metadata = {
|
|
problems: {
|
|
bitSample: [
|
|
new Problem("SPOJ", "Horrible Queries", "HORRIBLE", "Easy", false, ["BIT-Range"], ""),
|
|
],
|
|
bitProb: [
|
|
new Problem("CSES", "Polynomial Queries", "1736", "Normal", false, ["BIT-Range"], "equivalent to https://dmoj.ca/problem/acc3p4"),
|
|
],
|
|
lazySample: [
|
|
new Problem("CSES", "Range Updates & Sums", "1735", "Easy", false, ["Lazy SegTree"], ""),
|
|
],
|
|
lazySegTree: [
|
|
new Problem("YS", "Range Affine Range Sum", "range_affine_range_sum", "Easy", false, ["Lazy SegTree"], ""),
|
|
new Problem("Plat", "Counting Haybales", "578", "Easy", false, ["Lazy SegTree"], ""),
|
|
new Problem("Old Gold", "The Lazy Cow", "418", "Easy", false, ["Lazy SegTree"], ""),
|
|
],
|
|
lazySegCnt: [
|
|
new Problem("CSES", "Area of Rectangles", "1741", "Hard", false, ["Lazy SegTree"], ""),
|
|
new Problem("HR", "Strange Tree", "https://www.hackerrank.com/contests/openbracket-2017/challenges/special-path-on-a-strange-tree/problem", "Hard", false, ["Lazy SegTree"]),
|
|
],
|
|
segTreeBeats: [
|
|
new Problem("YS", "Range Chmin Chmax Add Range Sum", "range_chmin_chmax_add_range_sum", "Very Hard", false, ["SegTreeBeats"], ""),
|
|
],
|
|
}
|
|
};
|
|
|
|
## BIT Revisited
|
|
|
|
<problems-list problems={metadata.problems.bitSample} />
|
|
|
|
Binary Indexed Trees can support range increments in addition to range sum queries.
|
|
|
|
### Tutorial
|
|
|
|
<resources>
|
|
<resource source="GFG" title="Range Update Point Query" url="binary-indexed-tree-range-updates-point-queries/"></resource>
|
|
<resource source="GFG" title="Range Update Range Query" url="binary-indexed-tree-range-update-range-queries/"></resource>
|
|
</resources>
|
|
|
|
[My Implementation](https://github.com/bqi343/USACO/blob/master/Implementations/content/data-structures/1D%20Range%20Queries%20(9.2)/BITrange.h)
|
|
|
|
### Problems
|
|
|
|
<problems-list problems={metadata.problems.bitProb} />
|
|
|
|
## Lazy Segment Tree
|
|
|
|
<problems-list problems={metadata.problems.lazySample} />
|
|
|
|
### Tutorial
|
|
|
|
- CPH 28.1 (Segment Trees Revisited)
|
|
|
|
### Problems
|
|
|
|
<problems-list problems={metadata.problems.lazySegTree} />
|
|
|
|
## Lazy Segment Tree - Counting Minimums
|
|
|
|
use segment tree that keeps track of minimum and # of minimums
|
|
|
|
<problems-list problems={metadata.problems.lazySegCnt} />
|
|
|
|
## Segment Tree Beats
|
|
|
|
### Tutorial
|
|
|
|
<resources>
|
|
<resource source="CF" title="Intro to Segment Tree Beats" url="blog/entry/57319"></resource>
|
|
</resources>
|
|
|
|
### Problems
|
|
|
|
<problems-list problems={metadata.problems.segTreeBeats} />
|
|
|
|
(300iq insane problem)
|