From 3573d11f865bb6b60aaffbe8a4e3573686b6fc89 Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Sun, 15 Dec 2024 16:18:23 -0600 Subject: [PATCH 1/9] remove slow test LOL --- .../strings/longest_common_substring.test.cpp | 30 ------------------- 1 file changed, 30 deletions(-) delete mode 100644 tests/library_checker_aizu_tests/strings/longest_common_substring.test.cpp diff --git a/tests/library_checker_aizu_tests/strings/longest_common_substring.test.cpp b/tests/library_checker_aizu_tests/strings/longest_common_substring.test.cpp deleted file mode 100644 index 0902301d..00000000 --- a/tests/library_checker_aizu_tests/strings/longest_common_substring.test.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#define PROBLEM \ - "https://judge.yosupo.jp/problem/longest_common_substring" -#include "../template.hpp" -#include "../../../library/strings/suffix_array/suffix_array.hpp" -int main() { - cin.tie(0)->sync_with_stdio(0); - string s, t; - cin >> s >> t; - string both = s + '$' + t; - auto [sa, sa_inv, lcp] = get_sa(both, 256); - pair substr_s = {0, 0}, substr_t = {0, 0}; - for (int i = 0; i < sz(lcp); i++) { - if (both[sa[i]] == '$' || both[sa[i + 1]] == '$') - continue; - bool before_in_s = (sa[i] < sz(s)); - bool after_in_s = (sa[i + 1] < sz(s)); - if (before_in_s ^ after_in_s) { - if (lcp[i] > substr_s.second - substr_s.first) { - substr_s = {sa[i], sa[i] + lcp[i]}; - substr_t = {sa[i + 1], sa[i + 1] + lcp[i]}; - if (after_in_s) swap(substr_s, substr_t); - substr_t.first -= int(sz(s)) + 1; - substr_t.second -= int(sz(s)) + 1; - } - } - } - cout << substr_s.first << " " << substr_s.second << " " - << substr_t.first << " " << substr_t.second << '\n'; - return 0; -} From fe6e7d3fcf521782bf15dee38d3e5d66e27d1760 Mon Sep 17 00:00:00 2001 From: GitHub Date: Sun, 15 Dec 2024 22:22:05 +0000 Subject: [PATCH 2/9] [auto-verifier] verify commit 3573d11f865bb6b60aaffbe8a4e3573686b6fc89 --- .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 e9029bb6..f17d3925 100644 --- a/.verify-helper/timestamps.remote.json +++ b/.verify-helper/timestamps.remote.json @@ -128,6 +128,7 @@ "tests/library_checker_aizu_tests/trees/edge_cd_contour_range_query.test.cpp": "2024-12-14 18:43:21 -0600", "tests/library_checker_aizu_tests/trees/edge_cd_contour_range_update.test.cpp": "2024-12-14 18:43:21 -0600", "tests/library_checker_aizu_tests/trees/edge_cd_count_paths_per_length.test.cpp": "2024-12-14 18:43:21 -0600", +"tests/library_checker_aizu_tests/trees/edge_cd_reroot_dp.test.cpp": "2024-12-14 18:43:21 -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": "2024-12-15 14:34:10 -0600", "tests/library_checker_aizu_tests/trees/kth_path_tree_lift.test.cpp": "2024-12-15 14:34:10 -0600", From 470a1fd25e9963714871633a641fdf4c2b6086b3 Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Sun, 15 Dec 2024 16:43:32 -0600 Subject: [PATCH 3/9] trying this --- .../trees/edge_cd_reroot_dp.test.cpp | 53 +++++++++---------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/tests/library_checker_aizu_tests/trees/edge_cd_reroot_dp.test.cpp b/tests/library_checker_aizu_tests/trees/edge_cd_reroot_dp.test.cpp index 5fb07240..d13ca507 100644 --- a/tests/library_checker_aizu_tests/trees/edge_cd_reroot_dp.test.cpp +++ b/tests/library_checker_aizu_tests/trees/edge_cd_reroot_dp.test.cpp @@ -3,33 +3,31 @@ #include "../template.hpp" #include "../edge_cd_asserts.hpp" #include "../../../library/trees/edge_cd.hpp" +#include "../../../library/math/mod_int.hpp" int main() { cin.tie(0)->sync_with_stdio(0); int n; cin >> n; vector a(n); - vector res(n); + vector res(n); for (int i = 0; i < n; i++) { cin >> a[i]; res[i] = a[i]; } - vector> adj(n); - vector b(n - 1), c(n - 1); + vector> adj(n); + vector b(n - 1), c(n - 1); vector> par(n, {-1, -1}); - const int mod = 998'244'353; { vector>> adj_with_id(n); for (int i = 0; i < n - 1; i++) { int u, v; - cin >> u >> v >> b[i] >> c[i]; + cin >> u >> v >> b[i].x >> c[i].x; adj[u].push_back(v); adj[v].push_back(u); adj_with_id[u].emplace_back(v, i); adj_with_id[v].emplace_back(u, i); - res[u] += 1LL * b[i] * a[v] + c[i]; - res[u] %= mod; - res[v] += 1LL * b[i] * a[u] + c[i]; - res[v] %= mod; + res[u] = res[u] + b[i] * a[v] + c[i]; + res[v] = res[v] + b[i] * a[u] + c[i]; } auto dfs = [&](auto&& self, int u) -> void { for (auto [v, e_id] : adj_with_id[u]) @@ -44,22 +42,21 @@ int main() { assert(u_low ^ v_low); return u_low ? par[u].second : par[v].second; }; - { edge_cd(adj, edge_cd_asserts); } + //{ edge_cd(adj, edge_cd_asserts); } edge_cd(adj, - [&](const vector>& cd_adj, int cent, + [&](const vector>& cd_adj, int cent, int split) -> void { - array>, 2> all_backwards; - array sum_forward = {0, 0}, - cnt_nodes = {0, 0}; + array>, 2> all_backwards; + array sum_forward = {0, 0}; + array cnt_nodes = {0, 0}; auto dfs = [&](auto&& self, int u, int p, - array forwards, - array backwards, + array forwards, + array backwards, int side) -> void { all_backwards[side].push_back( {u, backwards[0], backwards[1]}); - sum_forward[side] += + sum_forward[side] = sum_forward[side] + forwards[0] * a[u] + forwards[1]; - sum_forward[side] %= mod; cnt_nodes[side]++; for (int v : cd_adj[u]) { if (v == p) continue; @@ -67,12 +64,12 @@ int main() { // f(x) = ax+b // g(x) = cx+d // f(g(x)) = a(cx+d)+b = acx+ad+b - array curr_forw = { - forwards[0] * b[e_id] % mod, - (forwards[0] * c[e_id] + forwards[1]) % mod}; - array curr_backw = { - b[e_id] * backwards[0] % mod, - (b[e_id] * backwards[1] + c[e_id]) % mod}; + array curr_forw = { + forwards[0] * b[e_id], + forwards[0] * c[e_id] + forwards[1]}; + array curr_backw = { + backwards[0] * b[e_id], + backwards[1] * b[e_id] + c[e_id]}; self(self, v, u, curr_forw, curr_backw, side); } }; @@ -84,13 +81,13 @@ int main() { for (int side = 0; side < 2; side++) { for ( auto [u, curr_b, curr_c] : all_backwards[side]) { - res[u] += curr_b * sum_forward[!side] + - cnt_nodes[!side] * curr_c; - res[u] %= mod; + res[u.x] = res[u.x] + + curr_b * sum_forward[!side] + + curr_c * cnt_nodes[!side]; } } }); - for (int i = 0; i < n; i++) cout << res[i] << ' '; + for (int i = 0; i < n; i++) cout << res[i].x << ' '; cout << '\n'; return 0; } From 9bb46da3a5bedd61fa5975ee6da85d9f651168d9 Mon Sep 17 00:00:00 2001 From: GitHub Date: Sun, 15 Dec 2024 22:46:13 +0000 Subject: [PATCH 4/9] [auto-verifier] verify commit 470a1fd25e9963714871633a641fdf4c2b6086b3 --- .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 f17d3925..262712f0 100644 --- a/.verify-helper/timestamps.remote.json +++ b/.verify-helper/timestamps.remote.json @@ -128,7 +128,7 @@ "tests/library_checker_aizu_tests/trees/edge_cd_contour_range_query.test.cpp": "2024-12-14 18:43:21 -0600", "tests/library_checker_aizu_tests/trees/edge_cd_contour_range_update.test.cpp": "2024-12-14 18:43:21 -0600", "tests/library_checker_aizu_tests/trees/edge_cd_count_paths_per_length.test.cpp": "2024-12-14 18:43:21 -0600", -"tests/library_checker_aizu_tests/trees/edge_cd_reroot_dp.test.cpp": "2024-12-14 18:43:21 -0600", +"tests/library_checker_aizu_tests/trees/edge_cd_reroot_dp.test.cpp": "2024-12-15 16:43:32 -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": "2024-12-15 14:34:10 -0600", "tests/library_checker_aizu_tests/trees/kth_path_tree_lift.test.cpp": "2024-12-15 14:34:10 -0600", From e1d14907f7a4b2392c4e3afd6c163d329e1de7ff Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Sun, 15 Dec 2024 16:49:53 -0600 Subject: [PATCH 5/9] trying this --- tests/library_checker_aizu_tests/edge_cd_asserts.hpp | 4 ++-- .../trees/edge_cd_reroot_dp.test.cpp | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/library_checker_aizu_tests/edge_cd_asserts.hpp b/tests/library_checker_aizu_tests/edge_cd_asserts.hpp index 61abe054..4a39fbbb 100644 --- a/tests/library_checker_aizu_tests/edge_cd_asserts.hpp +++ b/tests/library_checker_aizu_tests/edge_cd_asserts.hpp @@ -1,6 +1,6 @@ #pragma once -void edge_cd_asserts(const vector>& adj, - int cent, int split) { +void edge_cd_asserts(const vector& adj, int cent, + int split) { assert(0 < split && split < sz(adj[cent])); auto dfs = [&](auto&& self, int u, int p) -> int { int siz = 1; diff --git a/tests/library_checker_aizu_tests/trees/edge_cd_reroot_dp.test.cpp b/tests/library_checker_aizu_tests/trees/edge_cd_reroot_dp.test.cpp index d13ca507..382ca988 100644 --- a/tests/library_checker_aizu_tests/trees/edge_cd_reroot_dp.test.cpp +++ b/tests/library_checker_aizu_tests/trees/edge_cd_reroot_dp.test.cpp @@ -17,6 +17,7 @@ int main() { vector> adj(n); vector b(n - 1), c(n - 1); vector> par(n, {-1, -1}); + vector> base_adj(n); { vector>> adj_with_id(n); for (int i = 0; i < n - 1; i++) { @@ -24,6 +25,8 @@ int main() { cin >> u >> v >> b[i].x >> c[i].x; adj[u].push_back(v); adj[v].push_back(u); + base_adj[u].push_back(v); + base_adj[v].push_back(u); adj_with_id[u].emplace_back(v, i); adj_with_id[v].emplace_back(u, i); res[u] = res[u] + b[i] * a[v] + c[i]; @@ -42,7 +45,7 @@ int main() { assert(u_low ^ v_low); return u_low ? par[u].second : par[v].second; }; - //{ edge_cd(adj, edge_cd_asserts); } + { edge_cd(base_adj, edge_cd_asserts); } edge_cd(adj, [&](const vector>& cd_adj, int cent, int split) -> void { From 565a7abf4a6b101b00f4bc544adf9899e5102ced Mon Sep 17 00:00:00 2001 From: GitHub Date: Sun, 15 Dec 2024 22:57:44 +0000 Subject: [PATCH 6/9] [auto-verifier] verify commit e1d14907f7a4b2392c4e3afd6c163d329e1de7ff --- .verify-helper/timestamps.remote.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.verify-helper/timestamps.remote.json b/.verify-helper/timestamps.remote.json index 262712f0..3cc7bf60 100644 --- a/.verify-helper/timestamps.remote.json +++ b/.verify-helper/timestamps.remote.json @@ -66,7 +66,7 @@ "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/dynamic_bitset.test.cpp": "2024-11-22 10:47:44 -0600", -"tests/library_checker_aizu_tests/handmade_tests/edge_cd_small_trees.test.cpp": "2024-12-15 14:34:10 -0600", +"tests/library_checker_aizu_tests/handmade_tests/edge_cd_small_trees.test.cpp": "2024-12-15 16:49:53 -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 14:34:10 -0600", "tests/library_checker_aizu_tests/handmade_tests/lca_ladder_forest.test.cpp": "2024-12-14 19:50:29 -0600", @@ -125,10 +125,10 @@ "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", -"tests/library_checker_aizu_tests/trees/edge_cd_contour_range_query.test.cpp": "2024-12-14 18:43:21 -0600", -"tests/library_checker_aizu_tests/trees/edge_cd_contour_range_update.test.cpp": "2024-12-14 18:43:21 -0600", -"tests/library_checker_aizu_tests/trees/edge_cd_count_paths_per_length.test.cpp": "2024-12-14 18:43:21 -0600", -"tests/library_checker_aizu_tests/trees/edge_cd_reroot_dp.test.cpp": "2024-12-15 16:43:32 -0600", +"tests/library_checker_aizu_tests/trees/edge_cd_contour_range_query.test.cpp": "2024-12-15 16:49:53 -0600", +"tests/library_checker_aizu_tests/trees/edge_cd_contour_range_update.test.cpp": "2024-12-15 16:49:53 -0600", +"tests/library_checker_aizu_tests/trees/edge_cd_count_paths_per_length.test.cpp": "2024-12-15 16:49:53 -0600", +"tests/library_checker_aizu_tests/trees/edge_cd_reroot_dp.test.cpp": "2024-12-15 16:49:53 -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": "2024-12-15 14:34:10 -0600", "tests/library_checker_aizu_tests/trees/kth_path_tree_lift.test.cpp": "2024-12-15 14:34:10 -0600", From 247368a566148f4bf77b3d4eebdec78485669c76 Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Sun, 15 Dec 2024 16:56:37 -0600 Subject: [PATCH 7/9] update old var names --- library/graphs/functional_graph_processor.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/graphs/functional_graph_processor.hpp b/library/graphs/functional_graph_processor.hpp index d31acb04..f42e507e 100644 --- a/library/graphs/functional_graph_processor.hpp +++ b/library/graphs/functional_graph_processor.hpp @@ -2,8 +2,8 @@ //! https://github.com/Aeren1564/Algorithms/blob/master/Algorithm_Implementations_Cpp/Graph_Theory/Special_Graphs/functional_graph_processor.sublime-snippet //! @code //! // 0 <= a[i] < n -//! auto [t2, cycle] = func_graph(a); -//! auto [cyc_id, cyc_pos] = t2[v].root_of; +//! auto [t, cycle] = func_graph(a); +//! auto [cyc_id, cyc_pos] = t[v].root_of; //! int root = cycle[cyc_id][cyc_pos]; //! bool is_on_cycle = (v == root); //! @endcode From ed0577927b974709fd9c97f91dbdbb5a5580b783 Mon Sep 17 00:00:00 2001 From: GitHub Date: Sun, 15 Dec 2024 22:58:48 +0000 Subject: [PATCH 8/9] [auto-verifier] verify commit 247368a566148f4bf77b3d4eebdec78485669c76 --- .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 3cc7bf60..cb8a918c 100644 --- a/.verify-helper/timestamps.remote.json +++ b/.verify-helper/timestamps.remote.json @@ -68,7 +68,7 @@ "tests/library_checker_aizu_tests/handmade_tests/dynamic_bitset.test.cpp": "2024-11-22 10:47:44 -0600", "tests/library_checker_aizu_tests/handmade_tests/edge_cd_small_trees.test.cpp": "2024-12-15 16:49:53 -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 14:34:10 -0600", +"tests/library_checker_aizu_tests/handmade_tests/functional_graph.test.cpp": "2024-12-15 16:56:37 -0600", "tests/library_checker_aizu_tests/handmade_tests/lca_ladder_forest.test.cpp": "2024-12-14 19:50:29 -0600", "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", From 19a1051ff8eea351633c0db5b808a7031ad308e2 Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Sun, 15 Dec 2024 16:58:20 -0600 Subject: [PATCH 9/9] update --- 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 195c11de..62357e93 100644 --- a/tests/.config/.cppcheck_suppression_list +++ b/tests/.config/.cppcheck_suppression_list @@ -15,7 +15,7 @@ unusedScopedObject:../library/trees/centroid_decomp_uncommon/count_paths_per_nod unusedScopedObject:library_checker_aizu_tests/trees/centroid_path_dist.test.cpp:29 unusedScopedObject:../library/trees/edge_centroid_decomp_uncommon/count_paths_per_length.hpp:13 unusedScopedObject:library_checker_aizu_tests/trees/edge_cd_lca.test.cpp:20 -unusedScopedObject:library_checker_aizu_tests/trees/edge_cd_reroot_dp.test.cpp:48 +unusedScopedObject:library_checker_aizu_tests/trees/edge_cd_reroot_dp.test.cpp:49 unusedScopedObject:library_checker_aizu_tests/trees/cd_jump_on_tree.test.cpp:20 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