Skip to content

Commit 1c505fd

Browse files
committed
Merge branch 'dev' into golf_scc
2 parents d617a7a + 0b1c9d4 commit 1c505fd

File tree

18 files changed

+157
-87
lines changed

18 files changed

+157
-87
lines changed

.verify-helper/timestamps.remote.json

Lines changed: 56 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,36 @@
4949
"tests/library_checker_aizu_tests/flow/dinic_lib_checker.test.cpp": "2024-11-17 14:04:03 -0600",
5050
"tests/library_checker_aizu_tests/flow/hungarian.test.cpp": "2024-11-17 14:04:03 -0600",
5151
"tests/library_checker_aizu_tests/flow/min_cost_max_flow.test.cpp": "2024-12-05 10:41:42 -0600",
52+
"tests/library_checker_aizu_tests/graphs/biconnected_components.test.cpp": "2024-12-14 17:23:34 -0600",
53+
"tests/library_checker_aizu_tests/graphs/connected_components_of_complement_graph.test.cpp": "2024-12-14 17:23:34 -0600",
54+
"tests/library_checker_aizu_tests/graphs/dijkstra_aizu.test.cpp": "2024-12-14 17:23:34 -0600",
55+
"tests/library_checker_aizu_tests/graphs/dijkstra_lib_checker.test.cpp": "2024-12-14 17:23:34 -0600",
56+
"tests/library_checker_aizu_tests/graphs/directed_cycle.test.cpp": "2024-12-14 17:23:34 -0600",
57+
"tests/library_checker_aizu_tests/graphs/enumerate_triangles.test.cpp": "2024-11-17 14:04:03 -0600",
58+
"tests/library_checker_aizu_tests/graphs/hopcroft_karp_aizu.test.cpp": "2024-12-14 17:23:34 -0600",
59+
"tests/library_checker_aizu_tests/graphs/hopcroft_karp_lib_checker.test.cpp": "2024-12-14 17:23:34 -0600",
5260
"tests/library_checker_aizu_tests/graphs/mst.test.cpp": "2024-11-17 14:04:03 -0600",
53-
"tests/library_checker_aizu_tests/graphs/offline_incremental_scc.test.cpp": "2024-12-14 15:47:13 -0600",
54-
"tests/library_checker_aizu_tests/graphs/strongly_connected_components_aizu.test.cpp": "2024-12-14 15:47:13 -0600",
55-
"tests/library_checker_aizu_tests/graphs/strongly_connected_components_lib_checker.test.cpp": "2024-12-14 15:47:13 -0600",
56-
"tests/library_checker_aizu_tests/graphs/two_edge_components.test.cpp": "2024-12-14 15:47:13 -0600",
57-
"tests/library_checker_aizu_tests/handmade_tests/count_paths_forest.test.cpp": "2024-12-14 15:47:13 -0600",
61+
"tests/library_checker_aizu_tests/graphs/offline_incremental_scc.test.cpp": "2024-12-14 17:23:34 -0600",
62+
"tests/library_checker_aizu_tests/graphs/strongly_connected_components_aizu.test.cpp": "2024-12-14 17:23:34 -0600",
63+
"tests/library_checker_aizu_tests/graphs/strongly_connected_components_lib_checker.test.cpp": "2024-12-14 17:23:34 -0600",
64+
"tests/library_checker_aizu_tests/graphs/two_edge_components.test.cpp": "2024-12-14 17:23:34 -0600",
65+
"tests/library_checker_aizu_tests/handmade_tests/count_paths_forest.test.cpp": "2024-12-14 17:23:34 -0600",
5866
"tests/library_checker_aizu_tests/handmade_tests/dsu_size.test.cpp": "2024-11-17 14:04:03 -0600",
5967
"tests/library_checker_aizu_tests/handmade_tests/dynamic_bitset.test.cpp": "2024-11-22 10:47:44 -0600",
60-
"tests/library_checker_aizu_tests/handmade_tests/edge_cd_small_trees.test.cpp": "2024-12-14 15:47:13 -0600",
68+
"tests/library_checker_aizu_tests/handmade_tests/edge_cd_small_trees.test.cpp": "2024-12-14 17:23:34 -0600",
6169
"tests/library_checker_aizu_tests/handmade_tests/fib_matrix_expo.test.cpp": "2024-11-17 14:04:03 -0600",
6270
"tests/library_checker_aizu_tests/handmade_tests/functional_graph.test.cpp": "2024-12-05 10:41:42 -0600",
71+
"tests/library_checker_aizu_tests/handmade_tests/lca_ladder_forest.test.cpp": "2024-12-14 17:23:34 -0600",
72+
"tests/library_checker_aizu_tests/handmade_tests/manacher.test.cpp": "2024-12-14 18:40:37 -0600",
6373
"tests/library_checker_aizu_tests/handmade_tests/merge_st_and_wavelet.test.cpp": "2024-11-19 08:31:51 -0600",
6474
"tests/library_checker_aizu_tests/handmade_tests/mobius.test.cpp": "2024-11-17 14:04:03 -0600",
6575
"tests/library_checker_aizu_tests/handmade_tests/mod_int.test.cpp": "2024-11-17 14:04:03 -0600",
6676
"tests/library_checker_aizu_tests/handmade_tests/n_choose_k.test.cpp": "2024-11-17 14:04:03 -0600",
77+
"tests/library_checker_aizu_tests/handmade_tests/permutation_tree_small.test.cpp": "2024-12-14 15:47:13 -0600",
78+
"tests/library_checker_aizu_tests/handmade_tests/rmq_small_n.test.cpp": "2024-12-14 15:47:13 -0600",
79+
"tests/library_checker_aizu_tests/handmade_tests/sa_find_subarray.test.cpp": "2024-12-14 17:23:34 -0600",
80+
"tests/library_checker_aizu_tests/handmade_tests/seg_tree_find.test.cpp": "2024-12-14 15:47:13 -0600",
81+
"tests/library_checker_aizu_tests/handmade_tests/seg_tree_find_small.test.cpp": "2024-12-14 15:47:13 -0600",
6782
"tests/library_checker_aizu_tests/loops/chooses.test.cpp": "2024-11-17 14:04:03 -0600",
6883
"tests/library_checker_aizu_tests/loops/quotients.test.cpp": "2024-11-17 14:04:03 -0600",
6984
"tests/library_checker_aizu_tests/loops/submasks.test.cpp": "2024-11-17 14:04:03 -0600",
@@ -85,18 +100,40 @@
85100
"tests/library_checker_aizu_tests/math/solve_linear_mod.test.cpp": "2024-12-14 15:47:13 -0600",
86101
"tests/library_checker_aizu_tests/math/tetration.test.cpp": "2024-11-17 14:04:03 -0600",
87102
"tests/library_checker_aizu_tests/math/totient.test.cpp": "2024-11-17 14:04:03 -0600",
103+
"tests/library_checker_aizu_tests/math/xor_basis.test.cpp": "2024-12-14 15:47:13 -0600",
104+
"tests/library_checker_aizu_tests/math/xor_basis_intersection.test.cpp": "2024-12-14 15:47:13 -0600",
105+
"tests/library_checker_aizu_tests/monotonic_stack_related/cartesian_binary_tree.test.cpp": "2024-12-14 15:47:13 -0600",
106+
"tests/library_checker_aizu_tests/monotonic_stack_related/cartesian_k_ary_tree.test.cpp": "2024-12-14 15:47:13 -0600",
107+
"tests/library_checker_aizu_tests/monotonic_stack_related/count_rectangles.test.cpp": "2024-12-14 15:47:13 -0600",
108+
"tests/library_checker_aizu_tests/monotonic_stack_related/max_rect_histogram.test.cpp": "2024-12-14 15:47:13 -0600",
109+
"tests/library_checker_aizu_tests/strings/kmp.test.cpp": "2024-12-14 17:23:34 -0600",
110+
"tests/library_checker_aizu_tests/strings/lcp_array.test.cpp": "2024-12-14 17:23:34 -0600",
111+
"tests/library_checker_aizu_tests/strings/lcp_query_palindrome.test.cpp": "2024-12-14 17:23:34 -0600",
112+
"tests/library_checker_aizu_tests/strings/lcp_query_zfunc.test.cpp": "2024-12-14 17:23:34 -0600",
113+
"tests/library_checker_aizu_tests/strings/lcs_dp.test.cpp": "2024-12-05 10:41:42 -0600",
114+
"tests/library_checker_aizu_tests/strings/lcs_queries.test.cpp": "2024-12-14 17:23:34 -0600",
115+
"tests/library_checker_aizu_tests/strings/lcs_queries_merge_sort_tree.test.cpp": "2024-12-05 10:41:42 -0600",
116+
"tests/library_checker_aizu_tests/strings/longest_common_substring.test.cpp": "2024-12-14 17:23:34 -0600",
117+
"tests/library_checker_aizu_tests/strings/manacher.test.cpp": "2024-12-14 17:23:34 -0600",
118+
"tests/library_checker_aizu_tests/strings/multi_matching_bs.test.cpp": "2024-12-14 17:23:34 -0600",
119+
"tests/library_checker_aizu_tests/strings/prefix_function.test.cpp": "2024-11-17 14:04:03 -0600",
120+
"tests/library_checker_aizu_tests/strings/sa_cmp.test.cpp": "2024-12-14 17:23:34 -0600",
121+
"tests/library_checker_aizu_tests/strings/sa_sort_pairs.test.cpp": "2024-12-14 17:23:34 -0600",
122+
"tests/library_checker_aizu_tests/strings/single_matching_bs.test.cpp": "2024-12-14 17:23:34 -0600",
123+
"tests/library_checker_aizu_tests/strings/suffix_array.test.cpp": "2024-12-14 17:23:34 -0600",
124+
"tests/library_checker_aizu_tests/strings/suffix_array_short.test.cpp": "2024-12-14 17:23:34 -0600",
88125
"tests/library_checker_aizu_tests/strings/trie.test.cpp": "2024-12-05 10:41:42 -0600",
89-
"tests/library_checker_aizu_tests/strings/wildcard_pattern_matching.test.cpp": "2024-11-17 14:04:03 -0600",
90-
"tests/library_checker_aizu_tests/trees/cd_jump_on_tree.test.cpp": "2024-12-14 15:47:13 -0600",
91-
"tests/library_checker_aizu_tests/trees/cd_lca.test.cpp": "2024-12-14 15:47:13 -0600",
92-
"tests/library_checker_aizu_tests/trees/count_paths_per_length.test.cpp": "2024-12-14 15:47:13 -0600",
93-
"tests/library_checker_aizu_tests/trees/edge_cd_contour_range_query.test.cpp": "2024-12-14 15:47:13 -0600",
94-
"tests/library_checker_aizu_tests/trees/edge_cd_contour_range_update.test.cpp": "2024-12-14 15:47:13 -0600",
95-
"tests/library_checker_aizu_tests/trees/edge_cd_count_paths_per_length.test.cpp": "2024-12-14 15:47:13 -0600",
96-
"tests/library_checker_aizu_tests/trees/edge_cd_reroot_dp.test.cpp": "2024-12-14 15:47:13 -0600",
97-
"tests/library_checker_aizu_tests/trees/kth_node_on_path.test.cpp": "2024-12-14 15:47:13 -0600",
98-
"tests/library_checker_aizu_tests/trees/ladder_decomposition.test.cpp": "2024-11-17 14:04:03 -0600",
99-
"tests/library_checker_aizu_tests/trees/lca_all_methods_aizu.test.cpp": "2024-12-14 15:47:13 -0600",
100-
"tests/library_checker_aizu_tests/trees/lca_all_methods_lib_checker.test.cpp": "2024-12-14 15:47:13 -0600",
101-
"tests/library_checker_aizu_tests/trees/subtree_isomorphism.test.cpp": "2024-12-14 15:47:13 -0600"
126+
"tests/library_checker_aizu_tests/strings/wildcard_pattern_matching.test.cpp": "2024-12-14 17:23:34 -0600",
127+
"tests/library_checker_aizu_tests/trees/cd_jump_on_tree.test.cpp": "2024-12-14 17:23:34 -0600",
128+
"tests/library_checker_aizu_tests/trees/cd_lca.test.cpp": "2024-12-14 17:23:34 -0600",
129+
"tests/library_checker_aizu_tests/trees/count_paths_per_length.test.cpp": "2024-12-14 17:23:34 -0600",
130+
"tests/library_checker_aizu_tests/trees/edge_cd_contour_range_query.test.cpp": "2024-12-14 17:23:34 -0600",
131+
"tests/library_checker_aizu_tests/trees/edge_cd_contour_range_update.test.cpp": "2024-12-14 17:23:34 -0600",
132+
"tests/library_checker_aizu_tests/trees/edge_cd_count_paths_per_length.test.cpp": "2024-12-14 17:23:34 -0600",
133+
"tests/library_checker_aizu_tests/trees/edge_cd_reroot_dp.test.cpp": "2024-12-14 17:23:34 -0600",
134+
"tests/library_checker_aizu_tests/trees/kth_node_on_path.test.cpp": "2024-12-14 17:23:34 -0600",
135+
"tests/library_checker_aizu_tests/trees/ladder_decomposition.test.cpp": "2024-12-14 17:23:34 -0600",
136+
"tests/library_checker_aizu_tests/trees/lca_all_methods_aizu.test.cpp": "2024-12-14 17:23:34 -0600",
137+
"tests/library_checker_aizu_tests/trees/lca_all_methods_lib_checker.test.cpp": "2024-12-14 17:23:34 -0600",
138+
"tests/library_checker_aizu_tests/trees/subtree_isomorphism.test.cpp": "2024-12-14 17:23:34 -0600"
102139
}

library/graphs/bridges_cuts/block_vertex_tree.hpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
#pragma once
22
#include "cuts.hpp"
33
//! @code
4-
//! vector<vector<pii>> adj(n);
4+
//! {
5+
//! vector<vector<pii>> adj(n);
6+
//! cuts cc(adj, m);
7+
//! vector<vi> bvt = block_vertex_tree(adj, cc);
8+
//! }
9+
//! vector<basic_string<array<int, 2>>> adj(n);
510
//! cuts cc(adj, m);
611
//! vector<vi> bvt = block_vertex_tree(adj, cc);
7-
//! vector<basic_string<array<int, 2>>> adj1(n);
8-
//! cuts cc1(adj1, m);
9-
//! vector<vi> bvt1 = block_vertex_tree(adj1, cc1);
12+
//!
1013
//! //to loop over each unique bcc containing a node u:
1114
//! for (int bccid : bvt[v]) {
1215
//! bccid -= n;

library/graphs/bridges_cuts/bridge_tree.hpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
#pragma once
22
#include "bridges.hpp"
33
//! @code
4-
//! vector<vector<pii>> adj(n);
4+
//! {
5+
//! vector<vector<pii>> adj(n);
6+
//! bridges br(adj, m);
7+
//! vector<vi> bt = bridge_tree(adj, br);
8+
//! }
9+
//! vector<basic_string<array<int, 2>>> adj(n);
510
//! bridges br(adj, m);
611
//! vector<vi> bt = bridge_tree(adj, br);
7-
//! vector<basic_string<array<int, 2>>> adj1(n);
8-
//! bridges br1(adj1, m);
9-
//! vector<vi> bt1 = bridge_tree(adj1, br1);
1012
//! @endcode
1113
//! @time O(n + m)
1214
//! @space O(n)

library/graphs/bridges_cuts/bridges.hpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
#pragma once
22
//! https://cp-algorithms.com/graph/bridge-searching.html
33
//! @code
4-
//! vector<vector<pii>> adj(n);
4+
//! {
5+
//! vector<vector<pii>> adj(n);
6+
//! auto [num_ccs, br_id, is_br] = bridges(adj, m);
7+
//! }
8+
//! vector<basic_string<array<int, 2>>> adj(n);
59
//! rep (i, 0, m) {
610
//! int u, v;
711
//! cin >> u >> v;
812
//! u--, v--;
9-
//! adj[u].emplace_back(v, i);
10-
//! adj[v].emplace_back(u, i);
13+
//! adj[u].push_back({v, i});
14+
//! adj[v].push_back({u, i});
1115
//! }
12-
//! vector<basic_string<array<int,2>>> adj1(n);
13-
//! m);
16+
//! auto [num_ccs, br_id, is_br] = bridges(adj, m);
1417
//! @endcode
1518
//! is_br[edge id] = 1 iff bridge edge
1619
//! br_id[v] = id, 0<=id<num_ccs
1720
//! @time O(n + m)
1821
//! @space O(n + m)
19-
template<class G>
22+
template <class G>
2023
tuple<int, vi, vi> bridges(const G& adj, int m) {
2124
int n = sz(adj), num_ccs = 0, timer = 0;
2225
vi br_id(n, -1), is_br(m), tin(n), st;

library/graphs/bridges_cuts/cuts.hpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
#pragma once
22
//! https://cp-algorithms.com/graph/cutpoints.html
33
//! @code
4-
//! vector<vector<pii>> adj(n);
4+
//! {
5+
//! vector<vector<pii>> adj(n);
6+
//! auto [num_bccs, is_cut, bcc_id] = cuts(adj, m);
7+
//! }
8+
//! vector<basic_string<array<int, 2>>> adj(n);
59
//! rep (i, 0, m) {
610
//! int u, v;
711
//! cin >> u >> v;
812
//! u--, v--;
913
//! //self edges not allowed
10-
//! adj[u].emplace_back(v, i);
11-
//! adj[v].emplace_back(u, i);
14+
//! adj[u].push_back({v, i});
15+
//! adj[v].push_back({u, i});
1216
//! }
1317
//! auto [num_bccs, is_cut, bcc_id] = cuts(adj, m);
14-
//! vector<basic_string<array<int,2>>> adj1(n);
15-
//! auto [num_bccs1, is_cut1, bcc_id1] = cuts(adj1, m);
1618
//! @endcode
1719
//! is_cut[v] = 1 iff cut node
1820
//! bcc_id[edge id] = id, 0<=id<num_bccs

library/graphs/complement_graph_ccs.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
#pragma once
22
//! @code
3-
//! vector<vi> adj(n);
3+
//! {
4+
//! vector<vi> adj(n);
5+
//! vi cc_id = get_complement_graph_ccs(adj);
6+
//! }
7+
//! vector<basic_string<int>> adj;
48
//! vi cc_id = get_complement_graph_ccs(adj);
5-
//! vector<basic_string<int>> adj1;
6-
//! vi cc_id2 = get_complement_graph_ccs(adj1);
79
//! @endcode
810
//! 0<=cc_id[v]<number of connected components
911
//! in the complement graph

library/graphs/dijkstra.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
#pragma once
22
//! @code
3-
//! vector<vector<pair<int, ll>>> adj(n);
3+
//! {
4+
//! vector<vector<pair<int, ll>>> adj(n);
5+
//! auto d = dijkstra(adj, source);
6+
//! }
7+
//! vector<basic_string<array<int, 2>>> adj(n);
48
//! auto d = dijkstra(adj, source);
5-
//! vector<basic_string<array<int, 2>>> adj1(n);
6-
//! auto d1 = dijkstra(adj1, source);
79
//! @endcode
810
//! d[v] = min dist from source->..->v
911
//! @time O(n + (m log m))

library/graphs/hopcroft_karp.hpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
#pragma once
22
//! https://github.com/foreverbell/acm-icpc-cheat-sheet/blob/master/src/graph-algorithm/hopcroft-karp.cpp
33
//! @code
4-
//! vector<vi> adj(lsz);
4+
//! {
5+
//! vector<vi> adj(lsz);
6+
//! auto [matching_size, to_r, to_l,
7+
//! mvc_l, mvc_r] = hopcroft_karp(adj, rsz);
8+
//! }
9+
//! vector<basic_string<int>> adj(lsz);
510
//! adj[l].push_back(r); // add edge l <-> r
11+
//! // 0<=l<lsz; 0<=r<rsz
612
//! auto [matching_size, to_r, to_l,
713
//! mvc_l, mvc_r] = hopcroft_karp(adj, rsz);
8-
//! vector<basic_string<int>> adj1(lsz);
9-
//! hopcroft_karp match(adj1, rsz);
1014
//! @endcode
11-
//! 0<=l<lsz; 0<=r<rsz
1215
//! l <-> to_r[l] in matching if to_r[l]!=-1
1316
//! to_l[r] <-> r in matching if to_l[r]!=-1
1417
//! mvc_l[l] is 1 if l in Min Vertex Cover

library/graphs/strongly_connected_components/scc.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
#pragma once
22
//! https://github.com/kth-competitive-programming/kactl/blob/main/content/graph/SCC.h
33
//! @code
4-
//! vector<vi> adj(n);
4+
//! {
5+
//! vector<vi> adj(n);
6+
//! auto [num_sccs, scc_id] = sccs(adj);
7+
//! }
8+
//! vector<basic_string<int>> adj(n);
59
//! auto [num_sccs, scc_id] = sccs(adj);
6-
//! vector<basic_string<int>> adj1(n);
7-
//! auto [num_sccs1, scc_id1] = sccs(adj1);
810
//! @endcode
911
//! scc_id[v] = id, 0<=id<num_sccs
1012
//! for each edge u -> v: scc_id[u] >= scc_id[v]

library/trees/centroid_decomp.hpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
#pragma once
22
//! @code
3-
//! vector<vi> adj(n);
4-
//! centroid(adj, [&](const vector<vi>& adj,
5-
//! int cent, int par_cent) {
6-
//! });
7-
//! vector<basic_string<int>> adj1(n);
8-
//! centroid(adj1,
9-
//! [&](const vector<basic_string<int>>& adj1,
3+
//! {
4+
//! vector<vi> adj(n);
5+
//! centroid(adj, [&](const vector<vi>& adj,
6+
//! int cent, int par_cent) {
7+
//! });
8+
//! }
9+
//! vector<basic_string<int>> adj(n);
10+
//! centroid(adj,
11+
//! [&](const vector<basic_string<int>>& adj,
1012
//! int cent, int par_cent) {});
1113
//! @endcode
1214
//! @time O(n log n)

0 commit comments

Comments
 (0)