Skip to content

Commit ceca350

Browse files
authored
Refactor nxt function in seg_tree.hpp
1 parent 710e9d1 commit ceca350

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

library/data_structures_[l,r]/seg_tree.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
//! @time O(n + q log n)
1212
//! @space O(n)
1313
int nxt(int& l, int r) {
14-
int lg = __lg(min(l & -l, r - l + 1));
15-
return exchange(l, l + (1 << lg)) >> lg;
14+
int x = __lg(min(l & -l, r - l + 1));
15+
return (l += (1 << x)) >> x - 1;
16+
//return exchange(l, l + (1 << x)) >> x;
1617
}
1718
template<class T, class F> struct tree {
1819
int n;

0 commit comments

Comments
 (0)