|
1 | 1 | #pragma once |
2 | 2 | //! https://codeforces.com/blog/entry/118682 |
3 | 3 | //! @code |
4 | | -//! { |
5 | | -//! tree st(a, [&](int vl, int vr) { |
6 | | -//! return vl & vr; |
7 | | -//! }); |
8 | | -//! } |
9 | | -//! { |
10 | | -//! tree st(n, 0LL, plus<ll>{}); |
11 | | -//! } |
12 | | -//! { |
13 | | -//! tree st(n, INT_MAX, ranges::min); |
14 | | -//! int idx = st.walk(l, r, [&](int value) { |
15 | | -//! return value <= x; |
16 | | -//! }); // smallest index in [l, r] s.t. f is false |
17 | | -//! } |
| 4 | +//! tree st1(n, 0, [&](int vl, int vr) { |
| 5 | +//! return vl + vr; |
| 6 | +//! }); |
| 7 | +//! tree st(a, ranges::min); |
| 8 | +//! int idx = st.max_right(l, r, [&](int value) { |
| 9 | +//! return value <= x; |
| 10 | +//! }); |
| 11 | +//! // idx in [l, r+1] |
| 12 | +//! // f(op(a[l], a[l+1], ..., a[idx-1])) is true |
| 13 | +//! // f(op(a[l], a[l+1], ..., a[idx])) is false |
| 14 | +//! idx = st.min_left(l, r, [&](int value) { |
| 15 | +//! return value <= x; |
| 16 | +//! }); |
| 17 | +//! // idx in [l-1, r] |
| 18 | +//! // f(op(a[idx+1], ..., a[r-1], a[r])) is true |
| 19 | +//! // f(op(a[idx], ..., a[r-1], a[r])) is false |
18 | 20 | //! @endcode |
19 | 21 | //! @time O(n + q log n) |
20 | 22 | //! @space O(n) |
|
0 commit comments