Skip to content

Commit 3f170ef

Browse files
authored
Refactor nxt function for segment tree
1 parent 710e9d1 commit 3f170ef

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
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 = min<int>(l & -l, bit_floor(r - l + 1u)));
15+
return exchange(l, l + x) / x;
1616
}
1717
template<class T, class F> struct tree {
1818
int n;

0 commit comments

Comments
 (0)