Skip to content

Commit b741e86

Browse files
authored
Fix loop condition and variable initialization in walk.hpp
1 parent fce30fb commit b741e86

File tree

1 file changed

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

1 file changed

+3
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ int walk(int l, int r, const auto& f) {
1313
return u - n;
1414
}
1515
*/
16-
bool good=0;
17-
while (l < r) {
18-
int u = l + n, x = __lg(min(u & -u, r - l));
16+
int good=0;
17+
while (l <= r) {
18+
int u = l + n, x = __lg(min(u & -u, r - l +1-good));
1919
if (f(s[u >> x])) good=1,r = l + (1 << x) - 1;
2020
else l += 1 << x;
2121
}

0 commit comments

Comments
 (0)