summaryrefslogtreecommitdiff
path: root/datastructures
diff options
context:
space:
mode:
authormzuenni <michi.zuendorf@gmail.com>2023-02-23 14:57:25 +0100
committermzuenni <michi.zuendorf@gmail.com>2023-02-23 14:57:25 +0100
commitb40b4fbc8222226608c64013e56226044884374e (patch)
tree22c12297175a90fb1c696f8566c202900ce3c550 /datastructures
parente01dae0191e852da8c54f0bd1021d887f1665d29 (diff)
changed names
Diffstat (limited to 'datastructures')
-rw-r--r--datastructures/datastructures.tex2
-rw-r--r--datastructures/lazyPropagation.cpp8
2 files changed, 5 insertions, 5 deletions
diff --git a/datastructures/datastructures.tex b/datastructures/datastructures.tex
index 578eaba..dac8656 100644
--- a/datastructures/datastructures.tex
+++ b/datastructures/datastructures.tex
@@ -20,7 +20,7 @@
\subsubsection{Lazy Propagation}
Assignment modifications, sum queries \\
- \method{find\_first}{erster Index in [l, r) $\geq$ x (erfordert max-combine)}{\log(n)}
+ \method{lower\_bound}{erster Index in [l, r) $\geq$ x (erfordert max-combine)}{\log(n)}
\sourcecode{datastructures/lazyPropagation.cpp}
\end{algorithm}
diff --git a/datastructures/lazyPropagation.cpp b/datastructures/lazyPropagation.cpp
index 4817b16..ed5438f 100644
--- a/datastructures/lazyPropagation.cpp
+++ b/datastructures/lazyPropagation.cpp
@@ -61,15 +61,15 @@ struct SegTree {
}
// Optional:
- ll find_first(int l, int r, int x) {
+ ll lower_bound(int l, int r, int x) {
l += size, r += size;
push(l), push(r - 1);
- vector<pair<int, int>> a; stack<pair<int, int>> st;
+ vector<pair<int, int>> a, st;
for (int k = 1; l < r; l /= 2, r /= 2, k *= 2) {
if (l&1) a.emplace_back(l++, k);
- if (r&1) st.emplace(--r, k);
+ if (r&1) st.emplace_back(--r, k);
}
- while (!st.empty()) a.push_back(st.top()), st.pop();
+ a.insert(a.begin(), st.rbegin(), st.rend());
for (auto [i, k] : a) {
if (tree[i] >= x) return find(i, x, k); // Modify this
}