2525// ! such element exists then `r` is returned
2626// ! @time O(log(n))
2727// ! @space O(log(n)) for recursion stack
28- template <class F >
29- int find_first (int l, int r, const F& f) {
28+ int find_first (int l, int r, const auto & f) {
3029 return find_first_in_range (l, r, f, 0 , n, 1 );
3130}
3231// ! invariant: f(tree[v], tl, tr) is 1
33- template <class F >
34- int find_first_in_subtree (const F& f, int tl, int tr,
32+ int find_first_in_subtree (const auto & f, int tl, int tr,
3533 int v) {
3634 if (v >= n) return tl;
3735 int tm = split (tl, tr);
@@ -40,9 +38,8 @@ int find_first_in_subtree(const F& f, int tl, int tr,
4038 return find_first_in_subtree (f, tl, tm, 2 * v);
4139 return find_first_in_subtree (f, tm, tr, 2 * v + 1 );
4240}
43- template <class F >
44- int find_first_in_range (int l, int r, const F& f, int tl,
45- int tr, int v) {
41+ int find_first_in_range (int l, int r, const auto & f,
42+ int tl, int tr, int v) {
4643 if (r <= tl || tr <= l) return r;
4744 if (l <= tl && tr <= r)
4845 return f (tree[v], tl, tr)
0 commit comments