|
25 | 25 | //! such element exists then `r` is returned |
26 | 26 | //! @time O(log(n)) |
27 | 27 | //! @space O(log(n)) for recursion stack |
28 | | -int find_first(int l, int r, const auto& f) { |
| 28 | +int find_first(int l, int r, auto f) { |
29 | 29 | return find_first_in_range(l, r, f, 0, n, 1); |
30 | 30 | } |
31 | 31 | //! invariant: f(tree[v], tl, tr) is 1 |
32 | | -int find_first_in_subtree(const auto& f, int tl, int tr, |
33 | | - int v) { |
| 32 | +int find_first_in_subtree(auto f, int tl, int tr, int v) { |
34 | 33 | if (v >= n) return tl; |
35 | 34 | int tm = split(tl, tr); |
36 | 35 | push(tl, tm, tr, v); |
37 | 36 | if (f(tree[2 * v], tl, tm)) |
38 | 37 | return find_first_in_subtree(f, tl, tm, 2 * v); |
39 | 38 | return find_first_in_subtree(f, tm, tr, 2 * v + 1); |
40 | 39 | } |
41 | | -int find_first_in_range(int l, int r, const auto& f, |
42 | | - int tl, int tr, int v) { |
| 40 | +int find_first_in_range(int l, int r, auto f, int tl, |
| 41 | + int tr, int v) { |
43 | 42 | if (r <= tl || tr <= l) return r; |
44 | 43 | if (l <= tl && tr <= r) |
45 | 44 | return f(tree[v], tl, tr) |
|
0 commit comments