From 7a9ac3c0f1076b5fc37fe6be055403c29d58edd6 Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Wed, 15 Jan 2025 00:01:30 -0700 Subject: [PATCH 1/8] revert name back --- .../add_edges_strongly_connected.hpp | 0 .../offline_incremental_scc.hpp | 0 .../scc.hpp | 0 .../graphs/offline_incremental_scc.test.cpp | 11 +++++----- ..._connected_components_lib_checker.test.cpp | 7 +++--- .../scc_asserts.hpp | 22 +++++++++---------- 6 files changed, 18 insertions(+), 22 deletions(-) rename library/graphs/{scc => strongly_connected_components}/add_edges_strongly_connected.hpp (100%) rename library/graphs/{scc => strongly_connected_components}/offline_incremental_scc.hpp (100%) rename library/graphs/{scc => strongly_connected_components}/scc.hpp (100%) diff --git a/library/graphs/scc/add_edges_strongly_connected.hpp b/library/graphs/strongly_connected_components/add_edges_strongly_connected.hpp similarity index 100% rename from library/graphs/scc/add_edges_strongly_connected.hpp rename to library/graphs/strongly_connected_components/add_edges_strongly_connected.hpp diff --git a/library/graphs/scc/offline_incremental_scc.hpp b/library/graphs/strongly_connected_components/offline_incremental_scc.hpp similarity index 100% rename from library/graphs/scc/offline_incremental_scc.hpp rename to library/graphs/strongly_connected_components/offline_incremental_scc.hpp diff --git a/library/graphs/scc/scc.hpp b/library/graphs/strongly_connected_components/scc.hpp similarity index 100% rename from library/graphs/scc/scc.hpp rename to library/graphs/strongly_connected_components/scc.hpp diff --git a/tests/library_checker_aizu_tests/graphs/offline_incremental_scc.test.cpp b/tests/library_checker_aizu_tests/graphs/offline_incremental_scc.test.cpp index 603c7edd..919bc58b 100644 --- a/tests/library_checker_aizu_tests/graphs/offline_incremental_scc.test.cpp +++ b/tests/library_checker_aizu_tests/graphs/offline_incremental_scc.test.cpp @@ -1,9 +1,9 @@ -#define PROBLEM \ - "https://judge.yosupo.jp/problem/incremental_scc" -#include "../template.hpp" +#define PROBLEM "https://judge.yosupo.jp/problem/incremental_scc" +#include "../../../library/graphs/strongly_connected_components/offline_incremental_scc.hpp" + #include "../../../kactl/content/data-structures/UnionFind.h" -#include "../../../library/graphs/scc/offline_incremental_scc.hpp" #include "../../../library/math/mod_int.hpp" +#include "../template.hpp" int main() { cin.tie(0)->sync_with_stdio(0); int n, m; @@ -18,8 +18,7 @@ int main() { assert((eds[t][0] == eds[t][1]) == (joins[t] == -1)); vector order(m); iota(all(order), 0); - ranges::sort(all(order), {}, - [&](int i) { return joins[i]; }); + ranges::sort(all(order), {}, [&](int i) { return joins[i]; }); UF uf(n); mint sum = 0; for (int t = 0, it = 0; t < m; t++) { diff --git a/tests/library_checker_aizu_tests/graphs/strongly_connected_components_lib_checker.test.cpp b/tests/library_checker_aizu_tests/graphs/strongly_connected_components_lib_checker.test.cpp index 08d7e4fa..e8b2c431 100644 --- a/tests/library_checker_aizu_tests/graphs/strongly_connected_components_lib_checker.test.cpp +++ b/tests/library_checker_aizu_tests/graphs/strongly_connected_components_lib_checker.test.cpp @@ -1,7 +1,7 @@ #define PROBLEM "https://judge.yosupo.jp/problem/scc" -#include "../template.hpp" +#include "../../../library/graphs/strongly_connected_components/add_edges_strongly_connected.hpp" #include "../scc_asserts.hpp" -#include "../../../library/graphs/scc/add_edges_strongly_connected.hpp" +#include "../template.hpp" int main() { cin.tie(0)->sync_with_stdio(0); int n, m; @@ -16,8 +16,7 @@ int main() { auto [num_sccs, scc_id] = sccs(adj); cout << num_sccs << '\n'; vector> each_scc(num_sccs); - for (int i = 0; i < n; i++) - each_scc[scc_id[i]].push_back(i); + for (int i = 0; i < n; i++) each_scc[scc_id[i]].push_back(i); for (int i = num_sccs - 1; i >= 0; i--) { cout << sz(each_scc[i]) << " "; for (auto node : each_scc[i]) cout << node << " "; diff --git a/tests/library_checker_aizu_tests/scc_asserts.hpp b/tests/library_checker_aizu_tests/scc_asserts.hpp index b436c02a..cf2aed3a 100644 --- a/tests/library_checker_aizu_tests/scc_asserts.hpp +++ b/tests/library_checker_aizu_tests/scc_asserts.hpp @@ -1,7 +1,7 @@ #pragma once #include "../../library/contest/random.hpp" -#include "../../library/graphs/scc/add_edges_strongly_connected.hpp" -#include "../../library/graphs/scc/offline_incremental_scc.hpp" +#include "../../library/graphs/strongly_connected_components/add_edges_strongly_connected.hpp" +#include "../../library/graphs/strongly_connected_components/offline_incremental_scc.hpp" void scc_asserts(const vector>& adj) { int n = sz(adj); auto [num_sccs, scc_id] = sccs(adj); @@ -10,8 +10,7 @@ void scc_asserts(const vector>& adj) { for (int i = 0; i < n; i++) for (auto j : adj[i]) assert(scc_id[i] >= scc_id[j]); } - vector is_zero_in(num_sccs, 1), - is_zero_out(num_sccs, 1); + vector is_zero_in(num_sccs, 1), is_zero_out(num_sccs, 1); for (int i = 0; i < n; i++) { for (int v : adj[i]) { if (scc_id[i] == scc_id[v]) continue; @@ -21,14 +20,13 @@ void scc_asserts(const vector>& adj) { } // since {num_sccs-1, ..., 2, 1, 0} is a topo order assert(is_zero_in[num_sccs - 1] && is_zero_out[0]); - int num_zero_in = - int(count(begin(is_zero_in), end(is_zero_in), 1)); - int num_zero_out = - int(count(begin(is_zero_out), end(is_zero_out), 1)); - vector> edges = - extra_edges(adj, num_sccs, scc_id); - if (num_sccs == 1) assert(sz(edges) == 0); - else assert(sz(edges) == max(num_zero_in, num_zero_out)); + int num_zero_in = int(count(begin(is_zero_in), end(is_zero_in), 1)); + int num_zero_out = int(count(begin(is_zero_out), end(is_zero_out), 1)); + vector> edges = extra_edges(adj, num_sccs, scc_id); + if (num_sccs == 1) + assert(sz(edges) == 0); + else + assert(sz(edges) == max(num_zero_in, num_zero_out)); vector> adj_copy(adj); for (auto [u, v] : edges) { assert(u != v); From 752648178b25140ddec00c7e263995ee83ac620e Mon Sep 17 00:00:00 2001 From: GitHub Date: Wed, 15 Jan 2025 07:03:49 +0000 Subject: [PATCH 2/8] [auto-verifier] verify commit 7a9ac3c0f1076b5fc37fe6be055403c29d58edd6 --- .verify-helper/timestamps.remote.json | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.verify-helper/timestamps.remote.json b/.verify-helper/timestamps.remote.json index 08803305..b892b990 100644 --- a/.verify-helper/timestamps.remote.json +++ b/.verify-helper/timestamps.remote.json @@ -54,14 +54,11 @@ "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": "2024-12-15 14:34:10 -0600", +"tests/library_checker_aizu_tests/graphs/directed_cycle.test.cpp": "2025-01-15 00:01:30 -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/mst.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/graphs/offline_incremental_scc.test.cpp": "2024-12-15 14:34:10 -0600", -"tests/library_checker_aizu_tests/graphs/strongly_connected_components_aizu.test.cpp": "2024-12-15 14:34:10 -0600", -"tests/library_checker_aizu_tests/graphs/strongly_connected_components_lib_checker.test.cpp": "2024-12-15 14:34:10 -0600", "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", From 65a77bafdf95b1e2cb32b603e0595cc0b2236ad7 Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Wed, 15 Jan 2025 00:04:30 -0700 Subject: [PATCH 3/8] clang format now --- .../library_checker_aizu_tests/scc_asserts.hpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/tests/library_checker_aizu_tests/scc_asserts.hpp b/tests/library_checker_aizu_tests/scc_asserts.hpp index cf2aed3a..48edbaae 100644 --- a/tests/library_checker_aizu_tests/scc_asserts.hpp +++ b/tests/library_checker_aizu_tests/scc_asserts.hpp @@ -10,7 +10,8 @@ void scc_asserts(const vector>& adj) { for (int i = 0; i < n; i++) for (auto j : adj[i]) assert(scc_id[i] >= scc_id[j]); } - vector is_zero_in(num_sccs, 1), is_zero_out(num_sccs, 1); + vector is_zero_in(num_sccs, 1), + is_zero_out(num_sccs, 1); for (int i = 0; i < n; i++) { for (int v : adj[i]) { if (scc_id[i] == scc_id[v]) continue; @@ -20,13 +21,14 @@ void scc_asserts(const vector>& adj) { } // since {num_sccs-1, ..., 2, 1, 0} is a topo order assert(is_zero_in[num_sccs - 1] && is_zero_out[0]); - int num_zero_in = int(count(begin(is_zero_in), end(is_zero_in), 1)); - int num_zero_out = int(count(begin(is_zero_out), end(is_zero_out), 1)); - vector> edges = extra_edges(adj, num_sccs, scc_id); - if (num_sccs == 1) - assert(sz(edges) == 0); - else - assert(sz(edges) == max(num_zero_in, num_zero_out)); + int num_zero_in = + int(count(begin(is_zero_in), end(is_zero_in), 1)); + int num_zero_out = + int(count(begin(is_zero_out), end(is_zero_out), 1)); + vector> edges = + extra_edges(adj, num_sccs, scc_id); + if (num_sccs == 1) assert(sz(edges) == 0); + else assert(sz(edges) == max(num_zero_in, num_zero_out)); vector> adj_copy(adj); for (auto [u, v] : edges) { assert(u != v); From d942d637e251c997883f38a03e07d144dbed3075 Mon Sep 17 00:00:00 2001 From: GitHub Date: Wed, 15 Jan 2025 07:06:38 +0000 Subject: [PATCH 4/8] [auto-verifier] verify commit 65a77bafdf95b1e2cb32b603e0595cc0b2236ad7 --- .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 b892b990..9d1398bc 100644 --- a/.verify-helper/timestamps.remote.json +++ b/.verify-helper/timestamps.remote.json @@ -54,7 +54,7 @@ "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:01:30 -0700", +"tests/library_checker_aizu_tests/graphs/directed_cycle.test.cpp": "2025-01-15 00:04:30 -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", From 30f97776e16e8468543e9abc1e801fa6ffd04865 Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Wed, 15 Jan 2025 00:07:25 -0700 Subject: [PATCH 5/8] fixes --- .../graphs/offline_incremental_scc.test.cpp | 5 +++-- .../graphs/strongly_connected_components_aizu.test.cpp | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/library_checker_aizu_tests/graphs/offline_incremental_scc.test.cpp b/tests/library_checker_aizu_tests/graphs/offline_incremental_scc.test.cpp index 919bc58b..d7fc10ce 100644 --- a/tests/library_checker_aizu_tests/graphs/offline_incremental_scc.test.cpp +++ b/tests/library_checker_aizu_tests/graphs/offline_incremental_scc.test.cpp @@ -1,9 +1,10 @@ #define PROBLEM "https://judge.yosupo.jp/problem/incremental_scc" -#include "../../../library/graphs/strongly_connected_components/offline_incremental_scc.hpp" +#include "../template.hpp" +#include "../../../library/graphs/strongly_connected_components/offline_incremental_scc.hpp" #include "../../../kactl/content/data-structures/UnionFind.h" #include "../../../library/math/mod_int.hpp" -#include "../template.hpp" + int main() { cin.tie(0)->sync_with_stdio(0); int n, m; diff --git a/tests/library_checker_aizu_tests/graphs/strongly_connected_components_aizu.test.cpp b/tests/library_checker_aizu_tests/graphs/strongly_connected_components_aizu.test.cpp index e9e42a8d..0ad43f08 100644 --- a/tests/library_checker_aizu_tests/graphs/strongly_connected_components_aizu.test.cpp +++ b/tests/library_checker_aizu_tests/graphs/strongly_connected_components_aizu.test.cpp @@ -1,8 +1,8 @@ #define PROBLEM \ "https://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_3_C" -#include "../template.hpp" +#include "../../../library/graphs/strongly_connected_components/add_edges_strongly_connected.hpp" #include "../scc_asserts.hpp" -#include "../../../library/graphs/scc/add_edges_strongly_connected.hpp" +#include "../template.hpp" int main() { cin.tie(0)->sync_with_stdio(0); int n, m; From acac5a6a45325fd90541e80f44b69ef04e5a14ce Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Wed, 15 Jan 2025 00:08:16 -0700 Subject: [PATCH 6/8] fix --- .../graphs/strongly_connected_components_lib_checker.test.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/library_checker_aizu_tests/graphs/strongly_connected_components_lib_checker.test.cpp b/tests/library_checker_aizu_tests/graphs/strongly_connected_components_lib_checker.test.cpp index e8b2c431..68c3c4db 100644 --- a/tests/library_checker_aizu_tests/graphs/strongly_connected_components_lib_checker.test.cpp +++ b/tests/library_checker_aizu_tests/graphs/strongly_connected_components_lib_checker.test.cpp @@ -1,7 +1,9 @@ #define PROBLEM "https://judge.yosupo.jp/problem/scc" +#include "../template.hpp" + #include "../../../library/graphs/strongly_connected_components/add_edges_strongly_connected.hpp" #include "../scc_asserts.hpp" -#include "../template.hpp" + int main() { cin.tie(0)->sync_with_stdio(0); int n, m; From fe316212393452d51da3cea40ac3a8c5a9ba50c6 Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Wed, 15 Jan 2025 00:09:01 -0700 Subject: [PATCH 7/8] fix --- .../graphs/strongly_connected_components_aizu.test.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/library_checker_aizu_tests/graphs/strongly_connected_components_aizu.test.cpp b/tests/library_checker_aizu_tests/graphs/strongly_connected_components_aizu.test.cpp index 0ad43f08..a919230a 100644 --- a/tests/library_checker_aizu_tests/graphs/strongly_connected_components_aizu.test.cpp +++ b/tests/library_checker_aizu_tests/graphs/strongly_connected_components_aizu.test.cpp @@ -1,8 +1,10 @@ #define PROBLEM \ "https://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_3_C" +#include "../template.hpp" + #include "../../../library/graphs/strongly_connected_components/add_edges_strongly_connected.hpp" #include "../scc_asserts.hpp" -#include "../template.hpp" + int main() { cin.tie(0)->sync_with_stdio(0); int n, m; From 1d7bbdb0f6745ce302ecd6df68eb21d40e71631f Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Wed, 15 Jan 2025 00:10:46 -0700 Subject: [PATCH 8/8] fix path --- tests/.config/.cppcheck_suppression_list | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/.config/.cppcheck_suppression_list b/tests/.config/.cppcheck_suppression_list index 62357e93..b3abc40b 100644 --- a/tests/.config/.cppcheck_suppression_list +++ b/tests/.config/.cppcheck_suppression_list @@ -21,7 +21,7 @@ unusedScopedObject:library_checker_aizu_tests/trees/cd_jump_on_tree.test.cpp:58 arrayIndexOutOfBoundsCond:library_checker_aizu_tests/math/linear_prime_sieve.test.cpp:17 negativeContainerIndex:../library/strings/suffix_array/burrows_wheeler.hpp:50 useStlAlgorithm:../kactl/content/numerical/FastFourierTransform.h:53 -useStlAlgorithm:../library/graphs/scc/add_edges_strongly_connected.hpp:58 +useStlAlgorithm:../library/graphs/strongly_connected_components/add_edges_strongly_connected.hpp:58 useStlAlgorithm:../library/math/matrix_related/row_reduce.hpp:28 useStlAlgorithm:../library/math/count_paths/count_paths_triangle.hpp:24 useStlAlgorithm:../library/math/matrix_related/xor_basis_unordered_intersection.hpp:10