2020-06-24 23:08:16 +00:00
|
|
|
---
|
|
|
|
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.
|
2020-06-26 18:00:32 +00:00
|
|
|
frequency: 1
|
2020-06-24 23:08:16 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
import { Problem } from "../models";
|
|
|
|
|
|
|
|
export const metadata = {
|
|
|
|
problems: {
|
2020-06-26 21:12:04 +00:00
|
|
|
bitSample: [
|
|
|
|
new Problem("SPOJ", "Horrible Queries", "HORRIBLE", "Easy", false, ["BIT-Range"], ""),
|
|
|
|
],
|
|
|
|
bitProb: [
|
2020-06-30 20:25:02 +00:00
|
|
|
new Problem("CSES", "Polynomial Queries", "1736", "Easy", false, ["BIT-Range"], "equivalent to https://dmoj.ca/problem/acc3p4"),
|
2020-06-25 04:00:28 +00:00
|
|
|
],
|
2020-06-26 21:12:04 +00:00
|
|
|
lazySample: [
|
2020-06-24 23:08:16 +00:00
|
|
|
new Problem("CSES", "Range Updates & Sums", "1735", "Easy", false, ["Lazy SegTree"], ""),
|
2020-06-26 21:12:04 +00:00
|
|
|
],
|
|
|
|
lazySegTree: [
|
2020-06-25 04:00:28 +00:00
|
|
|
new Problem("YS", "Range Affine Range Sum", "range_affine_range_sum", "Easy", false, ["Lazy SegTree"], ""),
|
2020-06-24 23:08:16 +00:00
|
|
|
new Problem("Plat", "Counting Haybales", "578", "Easy", false, ["Lazy SegTree"], ""),
|
2020-06-26 21:12:04 +00:00
|
|
|
new Problem("Old Gold", "The Lazy Cow", "418", "Easy", false, ["Lazy SegTree"], ""),
|
2020-06-30 20:25:02 +00:00
|
|
|
new Problem("Plat", "Snow-Cow", "973", "Normal", false, ["Lazy SegTree"], "Can use lazy seg in place of two BITs"),
|
2020-06-27 00:33:06 +00:00
|
|
|
],
|
|
|
|
lazySegCnt: [
|
2020-06-28 16:03:46 +00:00
|
|
|
new Problem("CSES", "Area of Rectangles", "1741", "Normal", false, ["Lazy SegTree"], ""),
|
2020-06-30 20:25:02 +00:00
|
|
|
new Problem("HR", "Strange Tree", "https://www.hackerrank.com/contests/openbracket-2017/challenges/special-path-on-a-strange-tree/problem", "Very Hard", false, ["Lazy SegTree"]),
|
2020-06-24 23:08:16 +00:00
|
|
|
],
|
2020-06-25 04:00:28 +00:00
|
|
|
segTreeBeats: [
|
2020-06-30 20:25:02 +00:00
|
|
|
new Problem("YS", "Range Chmin Chmax Add Range Sum", "range_chmin_chmax_add_range_sum", "Very Hard", false, ["SegTreeBeats"], ""),
|
2020-06-24 23:08:16 +00:00
|
|
|
],
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-06-25 04:00:28 +00:00
|
|
|
## BIT Revisited
|
2020-06-24 23:08:16 +00:00
|
|
|
|
2020-06-26 21:12:04 +00:00
|
|
|
<problems-list problems={metadata.problems.bitSample} />
|
|
|
|
|
2020-06-25 04:00:28 +00:00
|
|
|
Binary Indexed Trees can support range increments in addition to range sum queries.
|
|
|
|
|
2020-06-26 21:12:04 +00:00
|
|
|
### Tutorial
|
|
|
|
|
2020-06-27 00:33:06 +00:00
|
|
|
<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)
|
2020-06-24 23:08:16 +00:00
|
|
|
|
2020-06-26 21:12:04 +00:00
|
|
|
### Problems
|
2020-06-24 23:08:16 +00:00
|
|
|
|
2020-06-26 21:12:04 +00:00
|
|
|
<problems-list problems={metadata.problems.bitProb} />
|
2020-06-25 04:00:28 +00:00
|
|
|
|
|
|
|
## Lazy Segment Tree
|
|
|
|
|
2020-06-26 21:12:04 +00:00
|
|
|
<problems-list problems={metadata.problems.lazySample} />
|
|
|
|
|
2020-06-25 04:00:28 +00:00
|
|
|
### Tutorial
|
|
|
|
|
2020-06-29 19:42:49 +00:00
|
|
|
<resources>
|
|
|
|
<resource source="CPH" title="28.1 - Segment Trees Revisited" starred>short description</resource>
|
|
|
|
<resource source="CSA" title="Segment Trees" url="segment_trees" starred>interactive</resource>
|
|
|
|
<resource source="cp-algo" title="Segment Tree" url="data_structures/segment_tree.html" starred>adding on segments, assigning</resource>
|
|
|
|
<resource source="CF" title="Efficient and easy segment trees" url="blog/entry/18051">code is more confusing than recursive version</resource>
|
|
|
|
</resources>
|
2020-06-25 04:00:28 +00:00
|
|
|
|
2020-06-26 21:12:04 +00:00
|
|
|
### Problems
|
|
|
|
|
2020-06-24 23:08:16 +00:00
|
|
|
<problems-list problems={metadata.problems.lazySegTree} />
|
|
|
|
|
2020-06-27 00:33:06 +00:00
|
|
|
## Lazy Segment Tree - Counting Minimums
|
|
|
|
|
|
|
|
use segment tree that keeps track of minimum and # of minimums
|
|
|
|
|
2020-06-28 16:03:46 +00:00
|
|
|
(describe)
|
2020-06-27 00:33:06 +00:00
|
|
|
|
2020-06-28 16:03:46 +00:00
|
|
|
<problems-list problems={metadata.problems.lazySegCnt} />
|