We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9e9d341 commit eb9f7c9Copy full SHA for eb9f7c9
1 file changed
library/data_structures_[l,r]/seg_tree_uncommon/walk.hpp
@@ -1,10 +1,9 @@
1
int walk(int l, int r, const auto& f) {
2
- l += n, r += n;
3
- if (T x = s[l]; f(x))
+ if (T x = s[l + n]; f(x))
4
for (l++; l <= r;) {
5
- int v = __lg(min(l & -l, r - l + 1));
6
- if (T y = op(x, s[l >> v]); f(y)) l += 1 << v, x = y;
+ int u = l + n, v = __lg(min(u & -u, r - l + 1));
+ if (T y = op(x, s[u >> v]); f(y)) l += 1 << v, x = y;
7
else r = l + (1 << v) - 2;
8
}
9
- return l - n;
+ return l;
10
0 commit comments