diff --git a/.verify-helper/timestamps.remote.json b/.verify-helper/timestamps.remote.json index eb1fffc0..581bb480 100644 --- a/.verify-helper/timestamps.remote.json +++ b/.verify-helper/timestamps.remote.json @@ -50,39 +50,19 @@ "tests/library_checker_aizu_tests/flow/dinic_aizu.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/flow/hungarian.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/flow/min_cost_max_flow.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/graphs/biconnected_components.test.cpp": "2024-12-15 09:01:54 -0600", +"tests/library_checker_aizu_tests/graphs/biconnected_components.test.cpp": "2025-02-10 14:02:17 -0700", "tests/library_checker_aizu_tests/graphs/connected_components_of_complement_graph.test.cpp": "2024-12-14 19:50:29 -0600", "tests/library_checker_aizu_tests/graphs/dijkstra_aizu.test.cpp": "2024-12-14 19:50:29 -0600", "tests/library_checker_aizu_tests/graphs/dijkstra_lib_checker.test.cpp": "2024-12-14 19:50:29 -0600", -"tests/library_checker_aizu_tests/graphs/directed_cycle.test.cpp": "2025-01-15 00:11:15 -0700", -"tests/library_checker_aizu_tests/graphs/enumerate_triangles.test.cpp": "2024-12-14 19:50:29 -0600", -"tests/library_checker_aizu_tests/graphs/hopcroft_karp_aizu.test.cpp": "2024-12-14 19:50:29 -0600", -"tests/library_checker_aizu_tests/graphs/hopcroft_karp_lib_checker.test.cpp": "2024-12-14 19:50:29 -0600", +"tests/library_checker_aizu_tests/graphs/directed_cycle.test.cpp": "2025-02-10 13:50:35 -0700", +"tests/library_checker_aizu_tests/graphs/enumerate_triangles.test.cpp": "2025-02-10 13:47:58 -0700", +"tests/library_checker_aizu_tests/graphs/hopcroft_karp_aizu.test.cpp": "2025-01-24 10:59:16 -0700", +"tests/library_checker_aizu_tests/graphs/hopcroft_karp_lib_checker.test.cpp": "2025-01-24 10:59:16 -0700", "tests/library_checker_aizu_tests/graphs/mst.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/graphs/offline_incremental_scc.test.cpp": "2025-02-10 14:50:36 -0700", -"tests/library_checker_aizu_tests/graphs/strongly_connected_components_aizu.test.cpp": "2025-02-10 14:50:36 -0700", -"tests/library_checker_aizu_tests/graphs/strongly_connected_components_lib_checker.test.cpp": "2025-02-10 14:50:36 -0700", -"tests/library_checker_aizu_tests/graphs/two_edge_components.test.cpp": "2024-12-15 09:01:54 -0600", -"tests/library_checker_aizu_tests/handmade_tests/count_paths_forest.test.cpp": "2024-12-15 14:34:10 -0600", -"tests/library_checker_aizu_tests/handmade_tests/dsu_size.test.cpp": "2024-12-14 19:50:29 -0600", -"tests/library_checker_aizu_tests/handmade_tests/edge_cd_small_trees.test.cpp": "2024-12-15 17:01:11 -0600", -"tests/library_checker_aizu_tests/handmade_tests/fib_matrix_expo.test.cpp": "2024-12-14 19:50:29 -0600", -"tests/library_checker_aizu_tests/handmade_tests/functional_graph.test.cpp": "2024-12-15 17:01:11 -0600", -"tests/library_checker_aizu_tests/handmade_tests/lca_ladder_forest.test.cpp": "2025-02-10 14:50:36 -0700", -"tests/library_checker_aizu_tests/handmade_tests/manacher.test.cpp": "2024-12-14 19:50:29 -0600", -"tests/library_checker_aizu_tests/handmade_tests/merge_st_and_wavelet.test.cpp": "2024-12-14 19:50:29 -0600", -"tests/library_checker_aizu_tests/handmade_tests/mobius.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/handmade_tests/mod_int.test.cpp": "2024-12-14 19:50:29 -0600", "tests/library_checker_aizu_tests/handmade_tests/n_choose_k.test.cpp": "2025-01-15 00:22:31 -0700", -"tests/library_checker_aizu_tests/handmade_tests/permutation_tree_small.test.cpp": "2024-12-14 15:47:13 -0600", +"tests/library_checker_aizu_tests/handmade_tests/permutation_tree_small.test.cpp": "2025-02-10 13:41:14 -0700", "tests/library_checker_aizu_tests/handmade_tests/rmq_small_n.test.cpp": "2024-12-14 19:50:29 -0600", -"tests/library_checker_aizu_tests/handmade_tests/sa_find_subarray.test.cpp": "2025-02-10 14:50:36 -0700", -"tests/library_checker_aizu_tests/handmade_tests/seg_tree_find.test.cpp": "2024-12-14 19:50:29 -0600", -"tests/library_checker_aizu_tests/handmade_tests/seg_tree_find_small.test.cpp": "2024-12-14 19:50:29 -0600", -"tests/library_checker_aizu_tests/loops/chooses.test.cpp": "2025-02-10 14:50:36 -0700", -"tests/library_checker_aizu_tests/loops/quotients.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/loops/submasks.test.cpp": "2025-02-10 14:50:36 -0700", -"tests/library_checker_aizu_tests/loops/supermasks.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/math/binary_exponentiation_mod.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/math/binary_matrix_mult.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/math/count_paths.test.cpp": "2025-01-15 00:22:31 -0700", @@ -95,32 +75,14 @@ "tests/library_checker_aizu_tests/math/mod_int_tetration.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/math/n_choose_k.test.cpp": "2025-01-15 00:22:31 -0700", "tests/library_checker_aizu_tests/math/num_subsequences.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/math/partitions.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/math/prime_sieve.test.cpp": "2024-11-22 11:54:52 -0600", "tests/library_checker_aizu_tests/math/solve_linear_mod.test.cpp": "2024-12-14 15:47:13 -0600", "tests/library_checker_aizu_tests/math/tetration.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/math/totient.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/math/xor_basis.test.cpp": "2025-02-10 14:50:36 -0700", -"tests/library_checker_aizu_tests/math/xor_basis_intersection.test.cpp": "2025-02-10 14:50:36 -0700", -"tests/library_checker_aizu_tests/monotonic_stack_related/cartesian_binary_tree.test.cpp": "2025-02-10 14:50:36 -0700", -"tests/library_checker_aizu_tests/monotonic_stack_related/cartesian_k_ary_tree.test.cpp": "2025-02-10 14:50:36 -0700", -"tests/library_checker_aizu_tests/monotonic_stack_related/count_rectangles.test.cpp": "2025-02-10 14:50:36 -0700", -"tests/library_checker_aizu_tests/monotonic_stack_related/max_rect_histogram.test.cpp": "2025-02-10 14:50:36 -0700", -"tests/library_checker_aizu_tests/strings/kmp.test.cpp": "2024-12-14 19:50:29 -0600", -"tests/library_checker_aizu_tests/strings/lcp_array.test.cpp": "2025-02-10 14:50:36 -0700", -"tests/library_checker_aizu_tests/strings/lcp_query_palindrome.test.cpp": "2025-02-10 14:50:36 -0700", -"tests/library_checker_aizu_tests/strings/lcp_query_zfunc.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/strings/lcs_dp.test.cpp": "2024-12-05 10:41:42 -0600", -"tests/library_checker_aizu_tests/strings/lcs_queries.test.cpp": "2024-12-14 19:50:29 -0600", +"tests/library_checker_aizu_tests/strings/lcs_queries.test.cpp": "2025-02-10 13:52:44 -0700", "tests/library_checker_aizu_tests/strings/lcs_queries_merge_sort_tree.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/strings/manacher.test.cpp": "2024-12-14 19:50:29 -0600", -"tests/library_checker_aizu_tests/strings/multi_matching_bs.test.cpp": "2025-02-10 14:50:36 -0700", -"tests/library_checker_aizu_tests/strings/prefix_function.test.cpp": "2025-02-10 14:50:36 -0700", -"tests/library_checker_aizu_tests/strings/sa_cmp.test.cpp": "2025-02-10 14:50:36 -0700", -"tests/library_checker_aizu_tests/strings/sa_sort_pairs.test.cpp": "2025-02-10 14:50:36 -0700", -"tests/library_checker_aizu_tests/strings/single_matching_bs.test.cpp": "2025-02-10 14:50:36 -0700", -"tests/library_checker_aizu_tests/strings/suffix_array.test.cpp": "2025-02-10 14:50:36 -0700", -"tests/library_checker_aizu_tests/strings/suffix_array_short.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/strings/trie.test.cpp": "2024-12-05 10:41:42 -0600", "tests/library_checker_aizu_tests/strings/wildcard_pattern_matching.test.cpp": "2024-12-14 19:50:29 -0600", "tests/library_checker_aizu_tests/trees/count_paths_per_length.test.cpp": "2024-12-15 14:34:10 -0600", @@ -129,9 +91,5 @@ "tests/library_checker_aizu_tests/trees/edge_cd_count_paths_per_length.test.cpp": "2024-12-15 17:01:11 -0600", "tests/library_checker_aizu_tests/trees/edge_cd_reroot_dp.test.cpp": "2024-12-15 17:01:11 -0600", "tests/library_checker_aizu_tests/trees/kth_path_ladder.test.cpp": "2024-12-15 14:34:10 -0600", -"tests/library_checker_aizu_tests/trees/kth_path_linear.test.cpp": "2025-02-10 14:50:36 -0700", -"tests/library_checker_aizu_tests/trees/kth_path_tree_lift.test.cpp": "2025-02-10 14:50:36 -0700", -"tests/library_checker_aizu_tests/trees/lca_all_methods_aizu.test.cpp": "2025-02-10 14:50:36 -0700", -"tests/library_checker_aizu_tests/trees/lca_all_methods_lib_checker.test.cpp": "2025-02-10 14:50:36 -0700", "tests/library_checker_aizu_tests/trees/subtree_isomorphism.test.cpp": "2024-12-15 14:34:10 -0600" } \ No newline at end of file diff --git a/library/data_structures/dsu/kruskal_tree.hpp b/library/data_structures/dsu/kruskal_tree.hpp index 745517c2..56b02e55 100644 --- a/library/data_structures/dsu/kruskal_tree.hpp +++ b/library/data_structures/dsu/kruskal_tree.hpp @@ -5,7 +5,7 @@ struct kr_tree { int id; vi p; - vector adj; + vector> adj; kr_tree(int n): id(n), p(2 * n, -1), adj(2 * n) {} int find(int v) { return p[v] < 0 ? v : p[v] = find(p[v]); diff --git a/library/data_structures/dsu/range_parallel_equivalence_classes.hpp b/library/data_structures/dsu/range_parallel_equivalence_classes.hpp index 65a82f50..730ce8f3 100644 --- a/library/data_structures/dsu/range_parallel_equivalence_classes.hpp +++ b/library/data_structures/dsu/range_parallel_equivalence_classes.hpp @@ -5,13 +5,13 @@ //! @time O((n + q) * \alpha(n)) //! @space O(n + q) UF get_rp_dsu(const vector>& rests, int n) { - vector>> rests_by_len(n + 1); + vector>> rests_by_len(n + 1); for (auto [l1, l2, len] : rests) - rests_by_len[len].push_back({l1, l2}); + rests_by_len[len] += {l1, l2}; UF uf(n); for (int len = n; len > 0; len--) for (auto [l1, l2] : rests_by_len[len]) if (uf.join(l1, l2)) - rests_by_len[len - 1].push_back({l1 + 1, l2 + 1}); + rests_by_len[len - 1] += {l1 + 1, l2 + 1}; return uf; } diff --git a/library/data_structures/seg_tree_uncommon/merge_sort_tree.hpp b/library/data_structures/seg_tree_uncommon/merge_sort_tree.hpp index 76be7d50..706a03d8 100644 --- a/library/data_structures/seg_tree_uncommon/merge_sort_tree.hpp +++ b/library/data_structures/seg_tree_uncommon/merge_sort_tree.hpp @@ -2,15 +2,13 @@ #include "../lazy_seg_tree_midpoint.hpp" struct merge_sort_tree { int n; - vector tree; + vector> tree; merge_sort_tree(const vi& a): n(sz(a)), tree(2 * n) { int pw2 = bit_ceil(size(a)); rep(i, 0, n) tree[(i + pw2) % n + n] = {a[i]}; for (int i = n - 1; i >= 1; i--) { - tree[i].resize( - sz(tree[2 * i]) + sz(tree[2 * i + 1])); ranges::merge(tree[2 * i], tree[2 * i + 1], - begin(tree[i])); + back_inserter(tree[i])); } } //! count of i in [l, r) such that a[i] in [vl, vr) diff --git a/library/data_structures/uncommon/mode_query.hpp b/library/data_structures/uncommon/mode_query.hpp index 1c1e205b..0eaf4a1c 100644 --- a/library/data_structures/uncommon/mode_query.hpp +++ b/library/data_structures/uncommon/mode_query.hpp @@ -4,7 +4,7 @@ const int b = 318; //!< sqrt(1e5) struct mode_query { int n; vi a, cnt, index_into_index; - vector index; + vector> index; vector> mode_blocks; //!< {mode, cnt} of range of blocks //! @param a compressed array: 0 <= a[i] < n @@ -16,7 +16,7 @@ struct mode_query { vector((n + b - 1) / b)) { rep(i, 0, n) { index_into_index[i] = sz(index[a[i]]); - index[a[i]].push_back(i); + index[a[i]] += i; } for (int start = 0; start < n; start += b) { int mode = a[start]; diff --git a/library/data_structures/uncommon/permutation_tree.hpp b/library/data_structures/uncommon/permutation_tree.hpp index 06201cd3..fbd98057 100644 --- a/library/data_structures/uncommon/permutation_tree.hpp +++ b/library/data_structures/uncommon/permutation_tree.hpp @@ -17,13 +17,13 @@ struct perm_tree { }; vector p; int root; - vector ch; + vector> ch; bool touches(int u, int v) { return p[u].mn_num == p[v].mn_num + p[v].len || p[v].mn_num == p[u].mn_num + p[u].len; } int allocate(int mn_i, int mn_v, int ln, bool join, - const vi& chs) { + const basic_string& chs) { p.push_back({mn_i, mn_v, ln, join}); ch.push_back(chs); return sz(ch) - 1; @@ -50,7 +50,7 @@ struct perm_tree { if (!empty(ch[u]) && touches(ch[u].back(), v)) { p[u].mn_num = min(p[u].mn_num, p[v].mn_num); p[u].len += p[v].len; - ch[u].push_back(v); + ch[u] += v; v = u; st.pop_back(); continue; @@ -73,7 +73,7 @@ struct perm_tree { break; } int min_num = p[v].mn_num; - vi chs(1 + sz(st) - idx, v); + basic_string chs(1 + sz(st) - idx, v); rep(j, idx, sz(st)) min_num = min(min_num, p[chs[j - idx] = st[j][0]].mn_num); v = allocate(l, min_num, i - l + 1, 0, chs); diff --git a/library/graphs/bridges_cuts/block_vertex_tree.hpp b/library/graphs/bridges_cuts/block_vertex_tree.hpp index 23702ac2..69d9e853 100644 --- a/library/graphs/bridges_cuts/block_vertex_tree.hpp +++ b/library/graphs/bridges_cuts/block_vertex_tree.hpp @@ -4,13 +4,12 @@ //! { //! vector> adj(n); //! auto [num_bccs, bcc_id, is_cut] = cuts(adj, m); -//! vector bvt = block_vertex_tree(adj, +//! auto bvt = block_vertex_tree(adj, //! num_bccs, bcc_id); //! } //! vector>> adj(n); //! auto [num_bccs, bcc_id, is_cut] = cuts(adj, m); -//! vector bvt = block_vertex_tree(adj, -//! num_bccs, bcc_id); +//! auto bvt = block_vertex_tree(adj, num_bccs, bcc_id); //! //! //to loop over each unique bcc containing a node u: //! for (int bccid : bvt[v]) { @@ -23,18 +22,18 @@ //! [n, n + num_bccs) are BCC nodes //! @time O(n + m) //! @time O(n) -vector block_vertex_tree(const auto& adj, int num_bccs, +auto block_vertex_tree(const auto& adj, int num_bccs, const vi& bcc_id) { int n = sz(adj); - vector bvt(n + num_bccs); + vector> bvt(n + num_bccs); vector vis(num_bccs); rep(i, 0, n) { for (auto [_, e_id] : adj[i]) { int bccid = bcc_id[e_id]; if (!vis[bccid]) { vis[bccid] = 1; - bvt[i].push_back(bccid + n); - bvt[bccid + n].push_back(i); + bvt[i] += bccid + n; + bvt[bccid + n] += i; } } for (int bccid : bvt[i]) vis[bccid - n] = 0; diff --git a/library/graphs/bridges_cuts/bridge_tree.hpp b/library/graphs/bridges_cuts/bridge_tree.hpp index a328c772..0781c50b 100644 --- a/library/graphs/bridges_cuts/bridge_tree.hpp +++ b/library/graphs/bridges_cuts/bridge_tree.hpp @@ -4,21 +4,18 @@ //! { //! vector> adj(n); //! auto [num_ccs, br_id, is_br] = bridges(adj, m); -//! vector bt = bridge_tree(adj, -//! num_ccs, br_id, is_br); +//! auto bt = bridge_tree(adj, num_ccs, br_id, is_br); //! } //! vector>> adj(n); //! auto [num_ccs, br_id, is_br] = bridges(adj, m); -//! vector bt = bridge_tree(adj, -//! num_ccs, br_id, is_br); +//! auto bt = bridge_tree(adj, num_ccs, br_id, is_br); //! @endcode //! @time O(n + m) //! @space O(n) -vector bridge_tree(const auto& adj, int num_ccs, +auto bridge_tree(const auto& adj, int num_ccs, const vi& br_id, const vi& is_br) { - vector tree(num_ccs); + vector> tree(num_ccs); rep(i, 0, sz(adj)) for (auto [u, e_id] : adj[i]) if ( - is_br[e_id]) tree[br_id[i]] - .push_back(br_id[u]); + is_br[e_id]) tree[br_id[i]] += br_id[u]; return tree; } diff --git a/library/graphs/bridges_cuts/bridges.hpp b/library/graphs/bridges_cuts/bridges.hpp index dfed7d03..5d1093d8 100644 --- a/library/graphs/bridges_cuts/bridges.hpp +++ b/library/graphs/bridges_cuts/bridges.hpp @@ -10,8 +10,8 @@ //! int u, v; //! cin >> u >> v; //! u--, v--; -//! adj[u].push_back({v, i}); -//! adj[v].push_back({u, i}); +//! adj[u] += {v, i}; +//! adj[v] += {u, i}; //! } //! auto [num_ccs, br_id, is_br] = bridges(adj, m); //! @endcode diff --git a/library/graphs/bridges_cuts/cuts.hpp b/library/graphs/bridges_cuts/cuts.hpp index 8aa7df2c..0a636e06 100644 --- a/library/graphs/bridges_cuts/cuts.hpp +++ b/library/graphs/bridges_cuts/cuts.hpp @@ -11,8 +11,8 @@ //! cin >> u >> v; //! u--, v--; //! //self edges not allowed -//! adj[u].push_back({v, i}); -//! adj[v].push_back({u, i}); +//! adj[u] += {v, i}; +//! adj[v] += {u, i}; //! } //! auto [num_bccs, bcc_id, is_cut] = cuts(adj, m); //! @endcode diff --git a/library/graphs/enumerate_triangles.hpp b/library/graphs/enumerate_triangles.hpp index 5c50437d..6e247cce 100644 --- a/library/graphs/enumerate_triangles.hpp +++ b/library/graphs/enumerate_triangles.hpp @@ -11,10 +11,10 @@ void enumerate_triangles(const vector& edges, int n, auto f) { vi deg(n); for (auto [u, v] : edges) deg[u]++, deg[v]++; - vector adj(n); + vector> adj(n); for (auto [u, v] : edges) { if (tie(deg[u], u) > tie(deg[v], v)) swap(u, v); - adj[u].push_back(v); + adj[u] += v; } vector seen(n); for (auto [u, v] : edges) { diff --git a/library/graphs/functional_graph_processor.hpp b/library/graphs/functional_graph_processor.hpp index f42e507e..6f0d2e81 100644 --- a/library/graphs/functional_graph_processor.hpp +++ b/library/graphs/functional_graph_processor.hpp @@ -14,7 +14,7 @@ struct func_graph { struct node { pii root_of; - vi childs; + basic_string childs; }; vector t; vector cycle; @@ -40,7 +40,7 @@ struct func_graph { int v = i; while (state[v] == 1) { t[v].root_of = t[u].root_of; - t[a[v]].childs.push_back(v); + t[a[v]].childs += v; state[v] = 2; v = a[v]; } diff --git a/library/graphs/hopcroft_karp.hpp b/library/graphs/hopcroft_karp.hpp index a97501b9..8b63b7e0 100644 --- a/library/graphs/hopcroft_karp.hpp +++ b/library/graphs/hopcroft_karp.hpp @@ -7,7 +7,7 @@ //! mvc_l, mvc_r] = hopcroft_karp(adj, rsz); //! } //! vector> adj(lsz); -//! adj[l].push_back(r); // add edge l <-> r +//! adj[l] += r; // add edge l <-> r //! // 0<=l extra_edges(const vector& adj, - int num_sccs, const vi& scc_id) { +vector extra_edges(const auto& adj, int num_sccs, + const vi& scc_id) { if (num_sccs == 1) return {}; int n = sz(adj); - vector scc_adj(num_sccs); + vector> scc_adj(num_sccs); vector zero_in(num_sccs, 1); rep(i, 0, n) for (int u : adj[i]) { if (scc_id[i] == scc_id[u]) continue; - scc_adj[scc_id[i]].push_back(scc_id[u]); + scc_adj[scc_id[i]] += scc_id[u]; zero_in[scc_id[u]] = 0; } vector vis(num_sccs); diff --git a/library/graphs/strongly_connected_components/offline_incremental_scc.hpp b/library/graphs/strongly_connected_components/offline_incremental_scc.hpp index 510791bd..5aca8ee3 100644 --- a/library/graphs/strongly_connected_components/offline_incremental_scc.hpp +++ b/library/graphs/strongly_connected_components/offline_incremental_scc.hpp @@ -29,7 +29,7 @@ vi offline_incremental_scc(vector> eds, adj.emplace_back(); } u = ids[u], v = ids[v]; - if (*it <= mid) adj[u].push_back(v); + if (*it <= mid) adj[u] += v; } rep(i, 0, sz(adj)) ids[vs[i]] = -1; scc_id = sccs(adj).second; diff --git a/library/math/matrix_related/xor_basis_unordered.hpp b/library/math/matrix_related/xor_basis_unordered.hpp index c1c85a4d..ba884bdb 100644 --- a/library/math/matrix_related/xor_basis_unordered.hpp +++ b/library/math/matrix_related/xor_basis_unordered.hpp @@ -17,6 +17,6 @@ template struct basis { return v; } bool insert(T v) { - return (v = shrink(v)) ? b.push_back(v), 1 : 0; + return (v = shrink(v)) ? b += v, 1 : 0; } }; diff --git a/library/math/matrix_related/xor_basis_unordered_intersection.hpp b/library/math/matrix_related/xor_basis_unordered_intersection.hpp index e6ac47b9..15dceaf6 100644 --- a/library/math/matrix_related/xor_basis_unordered_intersection.hpp +++ b/library/math/matrix_related/xor_basis_unordered_intersection.hpp @@ -7,13 +7,13 @@ template basis intersection(const basis& u, const basis& v) { basic_string> w; - for (T e : u.b) w.push_back({e, e}); + for (T e : u.b) w += {e, e}; basis res; for (T e : v.b) { T s = 0; for (auto [x, y] : w) if ((e ^ x) < e) e ^= x, s ^= y; - if (e) w.push_back({e, s}); + if (e) w += {e, s}; else res.insert(s); } return res; diff --git a/library/strings/longest_common_subsequence/lcs_queries.hpp b/library/strings/longest_common_subsequence/lcs_queries.hpp index 25c2872d..e7bf70f5 100644 --- a/library/strings/longest_common_subsequence/lcs_queries.hpp +++ b/library/strings/longest_common_subsequence/lcs_queries.hpp @@ -16,11 +16,11 @@ vi lcs_queries(const auto& s, const auto& t, const vector>& queries) { int n = sz(s), m = sz(t), q = sz(queries); - vector>> qs(n); + vector>> qs(n); rep(i, 0, q) { auto [s_r, t_le, t_ri] = queries[i]; if (s_r == 0 || t_le == m) continue; - qs[s_r - 1].push_back({t_le, t_ri, i}); + qs[s_r - 1] += {t_le, t_ri, i}; } lcs_dp lcs(t); vi res(q); diff --git a/library/trees/ladder_decomposition/ladder_decomposition.hpp b/library/trees/ladder_decomposition/ladder_decomposition.hpp index 15264021..1cfca41e 100644 --- a/library/trees/ladder_decomposition/ladder_decomposition.hpp +++ b/library/trees/ladder_decomposition/ladder_decomposition.hpp @@ -15,7 +15,7 @@ struct ladder { //! @param adj forest (rooted or unrooted) //! @time O(n log n) //! @space O(n log n) for b_tbl. Everything else is O(n) - ladder(const vector& adj): + ladder(const auto& adj): n(sz(adj)), d(n), p(n, -1), dl(n), idx_l(n) { auto dfs = [&](auto&& self, int v) -> void { dl[v] = v; diff --git a/library/trees/ladder_decomposition/linear_kth_par.hpp b/library/trees/ladder_decomposition/linear_kth_par.hpp index 3587a97d..6fde5810 100644 --- a/library/trees/ladder_decomposition/linear_kth_par.hpp +++ b/library/trees/ladder_decomposition/linear_kth_par.hpp @@ -14,11 +14,11 @@ //! @space O(n) struct linear_kth_par { struct node { - int d, p = -1, dl, idx_j, idx_l; + int d, p = -1, dl, idx_j; + basic_string lad; }; vector t; vector j; - vi l; linear_kth_par(const auto& adj): t(sz(adj)), j(2 * sz(t)) { vi st; @@ -47,9 +47,8 @@ struct linear_kth_par { if (t[i].p == -1) dfs(dfs, i); if (t[i].p == -1 || t[t[i].p].dl != t[i].dl) { int v = t[i].dl, len = (t[v].d - t[i].d) * 2; - t[v].idx_l = sz(l) + t[v].d; - for (; v != -1 && len--; v = t[v].p) - l.push_back(v); + auto& lad = t[v].lad; + for (; v != -1 && len--; v = t[v].p) lad += v; } } } @@ -62,8 +61,8 @@ struct linear_kth_par { default: int i = bit_floor(unsigned(k / 3)); auto [j1, j2] = j[(t[v].idx_j & -i) | i]; - int up = t[v].d - t[j2].d <= k ? j2 : j1; - return l[t[t[up].dl].idx_l - t[v].d + k]; + int leaf = t[t[v].d - t[j2].d <= k ? j2 : j1].dl; + return t[leaf].lad[k + t[leaf].d - t[v].d]; } } }; diff --git a/tests/.config/.cppcheck_suppression_list b/tests/.config/.cppcheck_suppression_list index 5cebe8c2..43162f09 100644 --- a/tests/.config/.cppcheck_suppression_list +++ b/tests/.config/.cppcheck_suppression_list @@ -60,3 +60,5 @@ uninitvar:library_checker_aizu_tests/handmade_tests/seg_tree_find_small.test.cpp unusedFunction:../kactl/content/data-structures/UnionFind.h:14 unusedFunction:../kactl/content/number-theory/ModPow.h:13 unusedFunction:../kactl/stress-tests/utilities/genTree.h:49 +assertWithSideEffect:library_checker_aizu_tests/math/xor_basis_intersection.test.cpp:27 +assertWithSideEffect:library_checker_aizu_tests/math/xor_basis_intersection.test.cpp:36 diff --git a/tests/library_checker_aizu_tests/graphs/biconnected_components.test.cpp b/tests/library_checker_aizu_tests/graphs/biconnected_components.test.cpp index f6449190..2be352ae 100644 --- a/tests/library_checker_aizu_tests/graphs/biconnected_components.test.cpp +++ b/tests/library_checker_aizu_tests/graphs/biconnected_components.test.cpp @@ -16,8 +16,7 @@ int main() { edges[i] = make_pair(u, v); } auto [num_bccs, bcc_id, is_cut] = cuts(adj, m); - vector> bvt = - block_vertex_tree(adj, num_bccs, bcc_id); + auto bvt = block_vertex_tree(adj, num_bccs, bcc_id); assert( find(begin(bcc_id), end(bcc_id), -1) == end(bcc_id)); for (int i = 0; i < n; i++) { diff --git a/tests/library_checker_aizu_tests/graphs/two_edge_components.test.cpp b/tests/library_checker_aizu_tests/graphs/two_edge_components.test.cpp index 1ab0e485..5c7602cb 100644 --- a/tests/library_checker_aizu_tests/graphs/two_edge_components.test.cpp +++ b/tests/library_checker_aizu_tests/graphs/two_edge_components.test.cpp @@ -17,8 +17,7 @@ int main() { edges[i] = {u, v}; } auto [num_ccs, br_id, is_br] = bridges(adj, m); - vector> bt = - bridge_tree(adj, num_ccs, br_id, is_br); + auto bt = bridge_tree(adj, num_ccs, br_id, is_br); assert(find(begin(br_id), end(br_id), -1) == end(br_id)); // check correctness of bridge tree { diff --git a/tests/library_checker_aizu_tests/handmade_tests/functional_graph.test.cpp b/tests/library_checker_aizu_tests/handmade_tests/functional_graph.test.cpp index 8bb0531a..4cb44c7c 100644 --- a/tests/library_checker_aizu_tests/handmade_tests/functional_graph.test.cpp +++ b/tests/library_checker_aizu_tests/handmade_tests/functional_graph.test.cpp @@ -1,5 +1,4 @@ -#define PROBLEM \ - "https://onlinejudge.u-aizu.ac.jp/problems/ITP1_1_A" +#define PROBLEM "https://onlinejudge.u-aizu.ac.jp/problems/ITP1_1_A" #include "../template.hpp" #include "../../../library/contest/random.hpp" #include "../../../library/graphs/functional_graph_processor.hpp" @@ -9,7 +8,7 @@ struct functional_graph_processor { init(sz(next)); build(next); } - template + template functional_graph_processor(const Graph_t &g) { init(g.n); build(g); @@ -101,24 +100,31 @@ struct functional_graph_processor { } int n; vector> cycle; - vector cycle_id; // id of the cycle it belongs to, - // -1 if not part of one - vector cycle_pos; // position in its cycle, -1 if - // not part of one - vector cycle_prev; // previous vertex in its cycle, - // -1 if not part of one - vector component_size; // size of its weakly - // connected component - vector root_of; // first reachable node in a cycle - vector depth; // distance to its root - vector> - abr; // forest of arborescences of reversed edges not - // on the cycles - vector order; // dfs order of abr - vector pos; // pos in the dfs order - vector end; // [pos[u], end[u]) denotes the subtree - vector size; // size of the subtree in abr + vector cycle_id; // id of the cycle it belongs to, + // -1 if not part of one + vector cycle_pos; // position in its cycle, -1 if + // not part of one + vector cycle_prev; // previous vertex in its cycle, + // -1 if not part of one + vector component_size; // size of its weakly + // connected component + vector root_of; // first reachable node in a cycle + vector depth; // distance to its root + vector> abr; // forest of arborescences of reversed edges not + // on the cycles + vector order; // dfs order of abr + vector pos; // pos in the dfs order + vector end; // [pos[u], end[u]) denotes the subtree + vector size; // size of the subtree in abr }; + +bool equal(const basic_string &a, const vi &b) { + if (sz(a) != sz(b)) return 0; + for (int i = 0; i < sz(a); i++) + if (a[i] != b[i]) return 0; + return 1; +} + int main() { cin.tie(0)->sync_with_stdio(0); for (int num_tests = 100; num_tests--;) { @@ -129,23 +135,19 @@ int main() { functional_graph_processor fgp(a); assert(cycle == fgp.cycle); for (int i = 0; i < n; i++) { - int root = - cycle[t[i].root_of.first][t[i].root_of.second]; + int root = cycle[t[i].root_of.first][t[i].root_of.second]; assert(root == fgp.root_of[i]); - assert(t[i].childs == fgp.abr[i]); + assert(equal(t[i].childs, fgp.abr[i])); assert((root == i) == (fgp.cycle_id[i] != -1)); if (root == i) { assert(t[i].root_of.first == fgp.cycle_id[i]); assert(t[i].root_of.second == fgp.cycle_pos[i]); int cyc_len = ssize(cycle[t[i].root_of.first]); - assert( - cycle[t[i].root_of.first] - [(t[i].root_of.second + 1) % cyc_len] == - a[i]); + assert(cycle[t[i].root_of.first][(t[i].root_of.second + 1) % cyc_len] == + a[i]); assert(fgp.cycle_prev[i] == - cycle[t[i].root_of.first] - [(t[i].root_of.second - 1 + cyc_len) % - cyc_len]); + cycle[t[i].root_of.first] + [(t[i].root_of.second - 1 + cyc_len) % cyc_len]); } else { assert(fgp.cycle_prev[i] == -1); }