Skip to content

Commit 3beb2d1

Browse files
authored
Fix boundary condition in segment tree walk
1 parent 4c88f61 commit 3beb2d1

File tree

1 file changed

+1
-1
lines changed
  • library/data_structures_[l,r]/seg_tree_uncommon

1 file changed

+1
-1
lines changed

library/data_structures_[l,r]/seg_tree_uncommon/walk.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ int walk(int l, int r, const auto& f) {
1515
*/
1616
while (l <= r) {
1717
int u = l + n, x = __lg(min(u & -u, r - l + 1));
18-
if (f(s[u >> x])) r = l + (1 << x) - 1;
18+
if (f(s[u >> x])) r = l + (1 << x) - 2;
1919
else l += 1 << x;
2020
}
2121
return -1;

0 commit comments

Comments
 (0)