Skip to content

Commit 98039c0

Browse files
committed
more changes
1 parent c0319a3 commit 98039c0

File tree

10 files changed

+17
-29
lines changed

10 files changed

+17
-29
lines changed

library/contest/random.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//! @endcode
1010
mt19937 rng(
1111
chrono::steady_clock::now().time_since_epoch().count());
12-
template<class T> T rnd(T l, T r) {
12+
auto rnd(auto l, auto r) {
1313
assert(l <= r);
14-
return uniform_int_distribution<T>(l, r)(rng);
14+
return uniform_int_distribution(l, r)(rng);
1515
}

library/data_structures/dsu/range_parallel_dsu.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,14 @@
88
struct rp_dsu {
99
vector<UF> ufs;
1010
rp_dsu(int n): ufs(bit_width(unsigned(n)), UF(n)) {}
11-
template<class F>
12-
void join(int l1, int l2, int len, const F& f) {
11+
void join(int l1, int l2, int len, const auto& f) {
1312
if (len == 0) return;
1413
int lg = __lg(len);
1514
join_impl(lg, l1, l2, f);
1615
join_impl(lg, l1 + len - (1 << lg),
1716
l2 + len - (1 << lg), f);
1817
}
19-
template<class F>
20-
void join_impl(int lvl, int u, int v, const F& f) {
18+
void join_impl(int lvl, int u, int v, const auto& f) {
2119
if (lvl == 0) {
2220
u = ufs[0].find(u);
2321
v = ufs[0].find(v);

library/data_structures/seg_tree_uncommon/find_first.hpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,11 @@
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)

library/data_structures/seg_tree_uncommon/find_last.hpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,11 @@
2525
//! such element exists then (l - 1) is returned
2626
//! @time O(log(n))
2727
//! @space O(log(n)) for recursion stack
28-
template<class F> int find_last(int l, int r, const F& f) {
28+
int find_last(int l, int r, const auto& f) {
2929
return find_last_in_range(l, r, f, 0, n, 1);
3030
}
3131
//! invariant: f(tree[v], tl, tr) is 1
32-
template<class F>
33-
int find_last_in_subtree(const F& f, int tl, int tr,
32+
int find_last_in_subtree(const auto& f, int tl, int tr,
3433
int v) {
3534
if (v >= n) return tl;
3635
int tm = split(tl, tr);
@@ -39,8 +38,7 @@ int find_last_in_subtree(const F& f, int tl, int tr,
3938
return find_last_in_subtree(f, tm, tr, 2 * v + 1);
4039
return find_last_in_subtree(f, tl, tm, 2 * v);
4140
}
42-
template<class F>
43-
int find_last_in_range(int l, int r, const F& f, int tl,
41+
int find_last_in_range(int l, int r, const auto& f, int tl,
4442
int tr, int v) {
4543
if (r <= tl || tr <= l) return l - 1;
4644
if (l <= tl && tr <= r)

library/graphs/enumerate_triangles.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77
//! @endcode
88
//! @time O(n + m ^ (3/2))
99
//! @space O(n + m)
10-
template<class F>
1110
void enumerate_triangles(const vector<pii>& edges, int n,
12-
F f) {
11+
auto f) {
1312
vi deg(n);
1413
for (auto [u, v] : edges) deg[u]++, deg[v]++;
1514
vector<vi> adj(n);

library/monotonic_stack/cartesian_k_ary_tree.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@
3131
//! @returns parent array
3232
//! @time O(n)
3333
//! @space a O(n) vector is allocated and returned
34-
template<class T>
35-
vi cart_k_ary_tree(const vector<T>& a, const vi& l) {
34+
vi cart_k_ary_tree(const auto& a, const vi& l) {
3635
vi p(l);
3736
for (int i = sz(a) - 1; i >= 0; i--)
3837
for (int j = i - 1; j != l[i]; j = l[j])

library/monotonic_stack/monotonic_stack.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
//! a[le[i]] < a[i]
88
//! @time O(n)
99
//! @space O(n)
10-
template<class T, class F>
11-
vi mono_st(const vector<T>& a, F cmp) {
10+
vi mono_st(const auto& a, auto cmp) {
1211
vi l(sz(a));
1312
rep(i, 0, sz(a)) for (
1413
l[i] = i - 1; l[i] >= 0 && !cmp(a[l[i]], a[i]);) l[i] =

library/strings/longest_common_subsequence/lcs_queries.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
//! ))
1414
//! @time O(n*m*log(m) + q*log(m) + q*log(q))
1515
//! @space O(n + m + q)
16-
template<class T>
17-
vi lcs_queries(const T& s, const T& t,
16+
vi lcs_queries(const auto& s, const auto& t,
1817
const vector<array<int, 3>>& queries) {
1918
int n = sz(s), m = sz(t), q = sz(queries);
2019
vector<vector<array<int, 3>>> qs(n);

library/strings/prefix_function.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//! https://cp-algorithms.com/string/prefix-function.html#implementation
33
//! @time O(n)
44
//! @space O(n)
5-
template<class T> vi prefix_function(const T& s) {
5+
vi prefix_function(const auto& s) {
66
vi pi(sz(s));
77
rep(i, 1, sz(s)) {
88
int j = pi[i - 1];

library/strings/wildcard_pattern_matching.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@ vector<vl> make_powers(const vl& v) {
1919
}
2020
return pws;
2121
}
22-
template<class F>
2322
vector<bool> wildcard_pattern_matching(const vl& s,
24-
const vl& t, F conv) {
23+
const vl& t, auto conv) {
2524
int n = sz(s), m = sz(t);
2625
auto s_pws = make_powers(s);
2726
auto t_pws = make_powers(t);

0 commit comments

Comments
 (0)