Skip to content

Commit eb9f7c9

Browse files
committed
golf
1 parent 9e9d341 commit eb9f7c9

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

  • library/data_structures_[l,r]/seg_tree_uncommon
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
int walk(int l, int r, const auto& f) {
2-
l += n, r += n;
3-
if (T x = s[l]; f(x))
2+
if (T x = s[l + n]; f(x))
43
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;
4+
int u = l + n, v = __lg(min(u & -u, r - l + 1));
5+
if (T y = op(x, s[u >> v]); f(y)) l += 1 << v, x = y;
76
else r = l + (1 << v) - 2;
87
}
9-
return l - n;
8+
return l;
109
}

0 commit comments

Comments
 (0)