From 33fcb6d40cea8ee8d6c1fbdf8e6a3b2123005031 Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Mon, 23 Jun 2025 18:54:33 -0600 Subject: [PATCH 1/8] add bridge test --- ... => bcc_callback_lib_checker_bcc.test.cpp} | 0 .../bcc_callback_lib_checker_two_cc.test.cpp | 49 +++++++++++++++++++ 2 files changed, 49 insertions(+) rename tests/library_checker_aizu_tests/graphs/{bcc_callback.test.cpp => bcc_callback_lib_checker_bcc.test.cpp} (100%) create mode 100644 tests/library_checker_aizu_tests/graphs/bcc_callback_lib_checker_two_cc.test.cpp diff --git a/tests/library_checker_aizu_tests/graphs/bcc_callback.test.cpp b/tests/library_checker_aizu_tests/graphs/bcc_callback_lib_checker_bcc.test.cpp similarity index 100% rename from tests/library_checker_aizu_tests/graphs/bcc_callback.test.cpp rename to tests/library_checker_aizu_tests/graphs/bcc_callback_lib_checker_bcc.test.cpp diff --git a/tests/library_checker_aizu_tests/graphs/bcc_callback_lib_checker_two_cc.test.cpp b/tests/library_checker_aizu_tests/graphs/bcc_callback_lib_checker_two_cc.test.cpp new file mode 100644 index 00000000..1937405b --- /dev/null +++ b/tests/library_checker_aizu_tests/graphs/bcc_callback_lib_checker_two_cc.test.cpp @@ -0,0 +1,49 @@ +#define PROBLEM \ + "https://judge.yosupo.jp/problem/two_edge_connected_components" +#include "../template.hpp" +#include "../../../library/graphs/bridges_cuts/bcc_callback.hpp" +#include "../../../kactl/content/data-structures/UnionFind.h" +int main() { + cin.tie(0)->sync_with_stdio(0); + int n, m; + cin >> n >> m; + vector> adj(n), adj_e_id(n); + for (int i = 0; i < n; i++) adj[i] += i; + for (int i = 0; i < m; i++) { + int u, v; + cin >> u >> v; + adj[u] += v; + adj[v] += u; + adj_e_id[u] += i; + adj_e_id[v] += i; + } + + UF uf(n); + vector seen(m); + bcc_callback(adj, [&](const vi& nodes) { + int cnt_edges = 0; + rep(i,0,sz(nodes)-1) + for(int e_id : adj_e_id[nodes[i]]) + if(!seen[e_id]) { + seen[e_id] = 1; + cnt_edges++; + } + if (cnt_edges >= 2) + for (int v : nodes) uf.join(v, nodes[0]); + }); + + vector> two_edge_ccs(n); + rep(i,0,n) two_edge_ccs[uf.find(i)] += i; + int cnt_ccs = 0; + rep(i,0,n) cnt_ccs += (!empty(two_edge_ccs[i])); + cout< Date: Mon, 23 Jun 2025 18:55:57 -0600 Subject: [PATCH 2/8] format test now --- .../bcc_callback_lib_checker_two_cc.test.cpp | 30 ++++++++----------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/tests/library_checker_aizu_tests/graphs/bcc_callback_lib_checker_two_cc.test.cpp b/tests/library_checker_aizu_tests/graphs/bcc_callback_lib_checker_two_cc.test.cpp index 1937405b..7fffbd82 100644 --- a/tests/library_checker_aizu_tests/graphs/bcc_callback_lib_checker_two_cc.test.cpp +++ b/tests/library_checker_aizu_tests/graphs/bcc_callback_lib_checker_two_cc.test.cpp @@ -17,33 +17,29 @@ int main() { adj_e_id[u] += i; adj_e_id[v] += i; } - UF uf(n); vector seen(m); bcc_callback(adj, [&](const vi& nodes) { int cnt_edges = 0; - rep(i,0,sz(nodes)-1) - for(int e_id : adj_e_id[nodes[i]]) - if(!seen[e_id]) { - seen[e_id] = 1; - cnt_edges++; - } + rep(i, 0, sz(nodes) - 1) for ( + int e_id : adj_e_id[nodes[i]]) if (!seen[e_id]) { + seen[e_id] = 1; + cnt_edges++; + } if (cnt_edges >= 2) for (int v : nodes) uf.join(v, nodes[0]); }); - vector> two_edge_ccs(n); - rep(i,0,n) two_edge_ccs[uf.find(i)] += i; + rep(i, 0, n) two_edge_ccs[uf.find(i)] += i; int cnt_ccs = 0; - rep(i,0,n) cnt_ccs += (!empty(two_edge_ccs[i])); - cout< Date: Tue, 24 Jun 2025 00:57:45 +0000 Subject: [PATCH 3/8] [auto-verifier] verify commit e0db1d5991819282a0093682caf6aa5a5b2014aa --- .verify-helper/timestamps.remote.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.verify-helper/timestamps.remote.json b/.verify-helper/timestamps.remote.json index 38feed82..3a69f142 100644 --- a/.verify-helper/timestamps.remote.json +++ b/.verify-helper/timestamps.remote.json @@ -50,7 +50,7 @@ "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/bcc_callback.test.cpp": "2025-06-23 18:39:53 -0600", +"tests/library_checker_aizu_tests/graphs/bcc_callback_lib_checker_bcc.test.cpp": "2025-06-23 18:54:33 -0600", "tests/library_checker_aizu_tests/graphs/biconnected_components.test.cpp": "2025-02-10 23:30:47 -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", From fff33a1342c889564e54f562909576665b64d0c5 Mon Sep 17 00:00:00 2001 From: GitHub Date: Tue, 24 Jun 2025 01:03:02 +0000 Subject: [PATCH 4/8] [auto-verifier] verify commit 28b5dd37854e3d0d96ea58e88f77792efa5ad41c --- .verify-helper/timestamps.remote.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.verify-helper/timestamps.remote.json b/.verify-helper/timestamps.remote.json index 3a69f142..e6e64da0 100644 --- a/.verify-helper/timestamps.remote.json +++ b/.verify-helper/timestamps.remote.json @@ -50,7 +50,7 @@ "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/bcc_callback_lib_checker_bcc.test.cpp": "2025-06-23 18:54:33 -0600", +"tests/library_checker_aizu_tests/graphs/bcc_callback_lib_checker_bcc.test.cpp": "2025-06-23 19:01:11 -0600", "tests/library_checker_aizu_tests/graphs/biconnected_components.test.cpp": "2025-02-10 23:30:47 -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", From 1c09658a1de5115a00bc8cd77c0d3d92e09e6622 Mon Sep 17 00:00:00 2001 From: GitHub Date: Tue, 24 Jun 2025 01:06:39 +0000 Subject: [PATCH 5/8] [auto-verifier] verify commit eba042398f8a897de330fc09c13d64c3f298625e --- .verify-helper/timestamps.remote.json | 1 + 1 file changed, 1 insertion(+) diff --git a/.verify-helper/timestamps.remote.json b/.verify-helper/timestamps.remote.json index 78589294..8f03374f 100644 --- a/.verify-helper/timestamps.remote.json +++ b/.verify-helper/timestamps.remote.json @@ -50,6 +50,7 @@ "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/bcc_callback_lib_checker_bcc.test.cpp": "2025-06-23 19:04:46 -0600", "tests/library_checker_aizu_tests/graphs/biconnected_components.test.cpp": "2025-02-10 23:30:47 -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", From cb52bd7138048bca75c15548f252c692179f415e Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Mon, 23 Jun 2025 19:07:56 -0600 Subject: [PATCH 6/8] add another test --- .../graphs/bcc_callback_aizu_bcc.test.cpp | 23 +++++++++++++++++++ .../bcc_callback_lib_checker_bcc.test.cpp | 8 +++---- 2 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 tests/library_checker_aizu_tests/graphs/bcc_callback_aizu_bcc.test.cpp diff --git a/tests/library_checker_aizu_tests/graphs/bcc_callback_aizu_bcc.test.cpp b/tests/library_checker_aizu_tests/graphs/bcc_callback_aizu_bcc.test.cpp new file mode 100644 index 00000000..d1f387b5 --- /dev/null +++ b/tests/library_checker_aizu_tests/graphs/bcc_callback_aizu_bcc.test.cpp @@ -0,0 +1,23 @@ +#define PROBLEM \ + "https://onlinejudge.u-aizu.ac.jp/problems/GRL_3_A" +#include "../template.hpp" +#include "../../../library/graphs/bridges_cuts/bcc_callback.hpp" +int main() { + cin.tie(0)->sync_with_stdio(0); + int n, m; + cin >> n >> m; + vector> adj(n); + for (int i = 0; i < n; i++) adj[i] += i; + for (int i = 0; i < m; i++) { + int u, v; + cin >> u >> v; + adj[u] += v; + adj[v] += u; + } + vi cnt(n); + bcc_callback(adj, [&](const vi& nodes) { + for (int v : nodes) cnt[v]++; + }); + rep(i, 0, n) if (cnt[i] >= 2) cout << i << '\n'; + return 0; +} diff --git a/tests/library_checker_aizu_tests/graphs/bcc_callback_lib_checker_bcc.test.cpp b/tests/library_checker_aizu_tests/graphs/bcc_callback_lib_checker_bcc.test.cpp index 2dffc95a..9dd2bfd0 100644 --- a/tests/library_checker_aizu_tests/graphs/bcc_callback_lib_checker_bcc.test.cpp +++ b/tests/library_checker_aizu_tests/graphs/bcc_callback_lib_checker_bcc.test.cpp @@ -16,10 +16,10 @@ int main() { } vector vis(n, 0); vector> all_bccs; - bcc_callback(adj, [&](const vi& nodes_bcc) { - assert(ssize(nodes_bcc) >= 2); - for (int v : nodes_bcc) vis[v] = 1; - all_bccs.push_back(nodes_bcc); + bcc_callback(adj, [&](const vi& nodes) { + assert(ssize(nodes) >= 2); + for (int v : nodes) vis[v] = 1; + all_bccs.push_back(nodes); }); for (int i = 0; i < n; i++) if (!vis[i]) all_bccs.push_back({i}); From e17d67d23c3089b5cd22aa349d46329087e6c52f Mon Sep 17 00:00:00 2001 From: GitHub Date: Tue, 24 Jun 2025 01:10:05 +0000 Subject: [PATCH 7/8] [auto-verifier] verify commit cb52bd7138048bca75c15548f252c692179f415e --- .verify-helper/timestamps.remote.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.verify-helper/timestamps.remote.json b/.verify-helper/timestamps.remote.json index 8f03374f..1e621169 100644 --- a/.verify-helper/timestamps.remote.json +++ b/.verify-helper/timestamps.remote.json @@ -50,7 +50,8 @@ "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/bcc_callback_lib_checker_bcc.test.cpp": "2025-06-23 19:04:46 -0600", +"tests/library_checker_aizu_tests/graphs/bcc_callback_aizu_bcc.test.cpp": "2025-06-23 19:07:56 -0600", +"tests/library_checker_aizu_tests/graphs/bcc_callback_lib_checker_bcc.test.cpp": "2025-06-23 19:07:56 -0600", "tests/library_checker_aizu_tests/graphs/biconnected_components.test.cpp": "2025-02-10 23:30:47 -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", From 29675af18903e696475649a94c590536f0fef073 Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Mon, 23 Jun 2025 19:13:55 -0600 Subject: [PATCH 8/8] add last test --- .../graphs/bcc_callback_aizu_bcc.test.cpp | 1 + .../bcc_callback_aizu_two_edge_cc.test.cpp | 28 +++++++++++++++++++ .../bcc_callback_lib_checker_two_cc.test.cpp | 1 + 3 files changed, 30 insertions(+) create mode 100644 tests/library_checker_aizu_tests/graphs/bcc_callback_aizu_two_edge_cc.test.cpp diff --git a/tests/library_checker_aizu_tests/graphs/bcc_callback_aizu_bcc.test.cpp b/tests/library_checker_aizu_tests/graphs/bcc_callback_aizu_bcc.test.cpp index d1f387b5..70145914 100644 --- a/tests/library_checker_aizu_tests/graphs/bcc_callback_aizu_bcc.test.cpp +++ b/tests/library_checker_aizu_tests/graphs/bcc_callback_aizu_bcc.test.cpp @@ -16,6 +16,7 @@ int main() { } vi cnt(n); bcc_callback(adj, [&](const vi& nodes) { + assert(sz(nodes) >= 2); for (int v : nodes) cnt[v]++; }); rep(i, 0, n) if (cnt[i] >= 2) cout << i << '\n'; diff --git a/tests/library_checker_aizu_tests/graphs/bcc_callback_aizu_two_edge_cc.test.cpp b/tests/library_checker_aizu_tests/graphs/bcc_callback_aizu_two_edge_cc.test.cpp new file mode 100644 index 00000000..f655d4cb --- /dev/null +++ b/tests/library_checker_aizu_tests/graphs/bcc_callback_aizu_two_edge_cc.test.cpp @@ -0,0 +1,28 @@ +#define PROBLEM \ + "https://onlinejudge.u-aizu.ac.jp/problems/GRL_3_B" +#include "../template.hpp" +#include "../../../library/graphs/bridges_cuts/bcc_callback.hpp" +int main() { + cin.tie(0)->sync_with_stdio(0); + int n, m; + cin >> n >> m; + vector> adj(n); + for (int i = 0; i < n; i++) adj[i] += i; + for (int i = 0; i < m; i++) { + int u, v; + cin >> u >> v; + adj[u] += v; + adj[v] += u; + } + vector bridges; + bcc_callback(adj, [&](const vi& nodes) { + assert(sz(nodes) >= 2); + if (sz(nodes) == 2) + bridges.push_back({min(nodes[0], nodes[1]), + max(nodes[0], nodes[1])}); + }); + ranges::sort(bridges); + for (auto [u, v] : bridges) + cout << u << ' ' << v << endl; + return 0; +} diff --git a/tests/library_checker_aizu_tests/graphs/bcc_callback_lib_checker_two_cc.test.cpp b/tests/library_checker_aizu_tests/graphs/bcc_callback_lib_checker_two_cc.test.cpp index 7fffbd82..200fb98f 100644 --- a/tests/library_checker_aizu_tests/graphs/bcc_callback_lib_checker_two_cc.test.cpp +++ b/tests/library_checker_aizu_tests/graphs/bcc_callback_lib_checker_two_cc.test.cpp @@ -20,6 +20,7 @@ int main() { UF uf(n); vector seen(m); bcc_callback(adj, [&](const vi& nodes) { + assert(sz(nodes) >= 2); int cnt_edges = 0; rep(i, 0, sz(nodes) - 1) for ( int e_id : adj_e_id[nodes[i]]) if (!seen[e_id]) {