File tree Expand file tree Collapse file tree
data_structures_[l,r)/seg_tree_uncommon
data_structures_[l,r]/seg_tree_uncommon
tests/library_checker_aizu_tests/data_structures Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11int walk (int l, int r, const auto & f) {
2+ T x = unit;
23 while (l < r) {
3- int u = l + n, x = __lg (min (u & -u, r - l));
4- if (f ( s[u >> x])) l += 1 << x ;
5- else r = l + (1 << x ) - 1 ;
4+ int u = l + n, v = __lg (min (u & -u, r - l));
5+ if (T y = op (x, s[u >> v]); f (y)) x = y, l += 1 << v ;
6+ else r = l + (1 << v ) - 1 ;
67 }
78 return l;
89}
Original file line number Diff line number Diff line change 11int walk (int l, int r, const auto & f) {
22 while (l <= r) {
3- int u = l + n, x = __lg (min (u & -u, r - l + 1 ));
4- if (f (s[u >> x ])) l += 1 << x ;
5- else r = l + (1 << x ) - 2 ;
3+ int u = l + n, v = __lg (min (u & -u, r - l + 1 ));
4+ if (f (s[u >> v ])) l += 1 << v ;
5+ else r = l + (1 << v ) - 2 ;
66 }
77 return l;
88}
Original file line number Diff line number Diff line change @@ -31,11 +31,8 @@ int main() {
3131 if (total == 0 ) {
3232 cout << -1 << ' \n ' ;
3333 } else {
34- int pref_sum = 0 ;
3534 cout << st.walk (0 , k + 1 , [&](int sum) {
36- if (pref_sum + sum < total)
37- return pref_sum += sum, 1 ;
38- return 0 ;
35+ return sum < total;
3936 }) << ' \n ' ;
4037 }
4138 }
You can’t perform that action at this time.
0 commit comments