diff options
| -rw-r--r-- | datastructures/lazyPropagation.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/datastructures/lazyPropagation.cpp b/datastructures/lazyPropagation.cpp index 7af1a6a..7811220 100644 --- a/datastructures/lazyPropagation.cpp +++ b/datastructures/lazyPropagation.cpp @@ -65,13 +65,12 @@ struct SegTree { ll lower_bound(int l, int r, T x) { l += n, r += n; push(l), push(r - 1); - vector<int> a, st; + int a[32] = {}, lp = 0, rp = 32; for (; l < r; l /= 2, r /= 2) { - if (l&1) a.push_back(l++); - if (r&1) st.push_back(--r); + if (l&1) a[lp++] = l++; + if (r&1) a[--rp] = --r; } - a.insert(a.end(), st.rbegin(), st.rend()); - for (int i : a) if (tree[i] >= x) { // Modify this + for (int i : a) if (i != 0 && tree[i] >= x) { // Modify this while (i < n) { push_down(i); if (tree[2 * i] >= x) i = 2 * i; // And this |
