Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions .verify-helper/timestamps.remote.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
"tests/library_checker_aizu_tests/graphs/strongly_connected_components_aizu.test.cpp": "2025-08-04 17:01:28 -0600",
"tests/library_checker_aizu_tests/graphs/strongly_connected_components_lib_checker.test.cpp": "2025-08-04 17:01:28 -0600",
"tests/library_checker_aizu_tests/graphs/two_edge_components.test.cpp": "2025-08-04 17:01:28 -0600",
"tests/library_checker_aizu_tests/handmade_tests/count_paths.test.cpp": "2025-08-05 15:52:46 -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": "2025-04-27 21:47:37 -0600",
"tests/library_checker_aizu_tests/handmade_tests/fib_matrix_expo.test.cpp": "2024-12-14 19:50:29 -0600",
Expand Down Expand Up @@ -126,15 +125,4 @@
"tests/library_checker_aizu_tests/strings/suffix_array_short.test.cpp": "2025-08-05 19:19:23 -0600",
"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": "2025-08-05 19:19:23 -0600",
"tests/library_checker_aizu_tests/trees/count_paths_per_length.test.cpp": "2025-08-05 15:52:46 -0600",
"tests/library_checker_aizu_tests/trees/edge_cd_contour_range_query.test.cpp": "2025-04-27 21:47:37 -0600",
"tests/library_checker_aizu_tests/trees/edge_cd_contour_range_update.test.cpp": "2025-04-27 21:47:37 -0600",
"tests/library_checker_aizu_tests/trees/edge_cd_count_paths_per_length.test.cpp": "2025-04-27 21:47:37 -0600",
"tests/library_checker_aizu_tests/trees/edge_cd_reroot_dp.test.cpp": "2025-04-27 21:47:37 -0600",
"tests/library_checker_aizu_tests/trees/kth_path_ladder.test.cpp": "2025-08-06 11:58:12 -0600",
"tests/library_checker_aizu_tests/trees/kth_path_linear.test.cpp": "2025-08-06 11:58:12 -0600",
"tests/library_checker_aizu_tests/trees/kth_path_tree_lift.test.cpp": "2025-08-05 15:52:46 -0600",
"tests/library_checker_aizu_tests/trees/lca_all_methods_aizu.test.cpp": "2025-08-06 09:59:41 -0600",
"tests/library_checker_aizu_tests/trees/lca_all_methods_lib_checker.test.cpp": "2025-08-06 09:59:41 -0600",
"tests/library_checker_aizu_tests/trees/subtree_isomorphism.test.cpp": "2025-08-05 18:22:08 -0600"
}
44 changes: 0 additions & 44 deletions library/trees/centroid_decomp_uncommon/count_paths_per_length.hpp

This file was deleted.

2 changes: 1 addition & 1 deletion library/trees/extra_members/in_subtree.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! returns 1 if v is in u's subtree
bool in_subtree(int u, int v) {
return in[u] <= in[v] && in[v] < in[u] + siz[u];
return tin[u] <= tin[v] && tin[v] < tin[u] + siz[u];
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
//! @space O(1)
int next_on_path(int u, int v) {
assert(u != v);
return in_subtree(u, v) ? rmq.query(in[u] + 1, in[v] + 1)
: p[u];
return in_subtree(u, v)
? rmq.query(tin[u] + 1, tin[v] + 1)
: p[u];
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include "../../monotonic_stack/monotonic_stack.hpp"
//! https://github.com/kth-competitive-programming/kactl/blob/main/content/graph/CompressTree.h
//! @code
//! vector<vi> adj(n);
Expand All @@ -11,7 +10,7 @@
//! @time O(|subset| log |subset|)
//! @space O(|subset|)
array<vi, 2> compress_tree(vi subset) {
auto proj = [&](int v) { return in[v]; };
auto proj = [&](int v) { return tin[v]; };
ranges::sort(subset, {}, proj);
int len = sz(subset);
rep(i, 1, len)
Expand Down
21 changes: 11 additions & 10 deletions library/trees/lca_rmq/lca_rmq.hpp → library/trees/lca_rmq.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once
#include "../../data_structures/rmq.hpp"
#include "../monotonic_stack/monotonic_stack.hpp"
#include "../data_structures/rmq.hpp"
//! https://github.com/kth-competitive-programming/kactl/blob/main/content/graph/LCA.h
//! @code
//! {
Expand All @@ -14,13 +15,13 @@
// NOLINTNEXTLINE(readability-identifier-naming)
struct LCA {
int n;
vi in, siz, d, p;
vi tin, siz, d, p;
RMQ<int, function<int(int, int)>> rmq = {{}, NULL};
LCA(const auto& adj):
n(sz(adj)), in(n), siz(n, 1), d(n), p(n) {
n(sz(adj)), tin(n), siz(n, 1), d(n), p(n) {
vi order;
auto dfs = [&](auto&& self, int v) -> void {
in[v] = sz(order), order.push_back(v);
tin[v] = sz(order), order.push_back(v);
for (int u : adj[v])
if (u != p[v])
d[u] = d[p[u] = v] + 1, self(self, u),
Expand All @@ -32,12 +33,12 @@ struct LCA {
}
int lca(int u, int v) {
if (u == v) return u;
auto [x, y] = minmax(in[u], in[v]);
auto [x, y] = minmax(tin[u], tin[v]);
return p[rmq.query(x + 1, y + 1)];
}
#include "../extra_members/dist_edges.hpp"
#include "../extra_members/in_subtree.hpp"
#include "../extra_members/on_path.hpp"
#include "next_on_path.hpp"
#include "../extra_members/compress_tree.hpp"
#include "extra_members/dist.hpp"
#include "extra_members/in_subtree.hpp"
#include "extra_members/on_path.hpp"
#include "extra_members/next_on_path.hpp"
#include "extra_members/virtual_tree.hpp"
};
2 changes: 1 addition & 1 deletion library/trees/linear_lca.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ struct linear_lca {
}
return d[u] < d[v] ? u : v;
}
#include "extra_members/dist_edges.hpp"
#include "extra_members/dist.hpp"
};
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ struct tree_lift {
else u = p[u], v = p[v];
return u;
}
#include "../extra_members/dist_edges.hpp"
#include "extra_members/dist.hpp"
};
1 change: 0 additions & 1 deletion tests/.config/.cppcheck_suppression_list
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ knownConditionTrueFalse:../library/strings/suffix_array/suffix_array_short.hpp:2
knownConditionTrueFalse:../library/data_structures/dsu/kruskal_tree.hpp:15
constVariable:../kactl/content/numerical/NumberTheoreticTransform.h:30
constVariable:../kactl/content/graph/CompressTree.h:20
functionStatic:../library/monotonic_stack/monotonic_stack.hpp:10
constVariableReference:../kactl/content/graph/CompressTree.h:20
constVariableReference:../library/flow/min_cost_max_flow.hpp:43
constVariableReference:library_checker_aizu_tests/graphs/connected_components_of_complement_graph.test.cpp:21
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"https://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_1_A"
#include "../template.hpp"
#include "../../../library/contest/random.hpp"
#include "../../../library/trees/centroid_decomp_uncommon/count_paths_per_node.hpp"
#include "../../../library/trees/lca_rmq/lca_rmq.hpp"
#include "../../../library/trees/centroid_decomp_uncommon/count_paths_per_length.hpp"
#include "../../../library/trees/uncommon/count_paths_per_node.hpp"
#include "../../../library/trees/lca_rmq.hpp"
#include "../../../library/trees/uncommon/count_paths_per_length.hpp"
#include "../cd_asserts.hpp"
vector<vector<ll>> naive(const vector<vi>& adj) {
LCA lc(adj);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#define PROBLEM \
"https://judge.yosupo.jp/problem/frequency_table_of_tree_distance"
#include "../template.hpp"
#include "../../../library/trees/centroid_decomp_uncommon/count_paths_per_length.hpp"
#include "../../../library/trees/uncommon/count_paths_per_length.hpp"
int main() {
cin.tie(0)->sync_with_stdio(0);
int n;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"https://judge.yosupo.jp/problem/vertex_add_range_contour_sum_on_tree"
#include "../template.hpp"
#include "../edge_cd_asserts.hpp"
#include "../../../library/trees/edge_centroid_decomp_uncommon/contour_range_query.hpp"
#include "../../../library/trees/uncommon/contour_range_query.hpp"
int main() {
cin.tie(0)->sync_with_stdio(0);
int n, q;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"https://judge.yosupo.jp/problem/vertex_get_range_contour_add_on_tree"
#include "../template.hpp"
#include "../edge_cd_asserts.hpp"
#include "../../../library/trees/edge_centroid_decomp_uncommon/contour_range_update.hpp"
#include "../../../library/trees/uncommon/contour_range_update.hpp"
int main() {
cin.tie(0)->sync_with_stdio(0);
int n, q;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"https://judge.yosupo.jp/problem/frequency_table_of_tree_distance"
#include "../template.hpp"
#include "../edge_cd_asserts.hpp"
#include "../../../library/trees/edge_centroid_decomp_uncommon/count_paths_per_length.hpp"
#include "../../../library/trees/uncommon/count_paths_per_length.hpp"
int main() {
cin.tie(0)->sync_with_stdio(0);
int n;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#define PROBLEM \
"https://judge.yosupo.jp/problem/jump_on_tree"
#include "../template.hpp"
#include "../../../library/trees/ladder_decomposition/ladder_decomposition.hpp"
#include "../../../library/trees/ladder_decomposition/linear_kth_par.hpp"
#include "../../../library/trees/uncommon/ladder_decomposition.hpp"
#include "../../../library/trees/linear_kth_par.hpp"
int main() {
cin.tie(0)->sync_with_stdio(0);
int n, q;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"https://judge.yosupo.jp/problem/jump_on_tree"
#include "../template.hpp"
#include "../../../library/trees/linear_lca.hpp"
#include "../../../library/trees/ladder_decomposition/linear_kth_par.hpp"
#include "../../../library/trees/lca_rmq/lca_rmq.hpp"
#include "../../../library/trees/linear_kth_par.hpp"
#include "../../../library/trees/lca_rmq.hpp"
#include "../compress_tree_asserts.hpp"
int main() {
cin.tie(0)->sync_with_stdio(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"https://judge.yosupo.jp/problem/jump_on_tree"
#include "../template.hpp"
#include "../../../library/contest/random.hpp"
#include "../../../library/trees/tree_lift/tree_lift.hpp"
#include "../../../library/trees/lca_rmq/lca_rmq.hpp"
#include "../../../library/trees/tree_lift.hpp"
#include "../../../library/trees/lca_rmq.hpp"
int main() {
cin.tie(0)->sync_with_stdio(0);
int n, q;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#define PROBLEM \
"https://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_5_C"
#include "../template.hpp"
#include "../../../library/monotonic_stack/monotonic_stack.hpp"
#include "../../../library/trees/tree_lift/tree_lift.hpp"
#include "../../../library/trees/tree_lift.hpp"
#include "../../../library/trees/linear_lca.hpp"
#include "../../../library/trees/lca_rmq/lca_rmq.hpp"
#include "../../../library/trees/lca_rmq.hpp"
#include "../compress_tree_asserts.hpp"
int main() {
cin.tie(0)->sync_with_stdio(0);
Expand All @@ -25,8 +24,8 @@ int main() {
assert(tl.lca(i, i) == i);
assert(lc.lca(i, i) == i);
assert(lin_lca.lca(i, i) == i);
assert(lc.in[lc.rmq.dp[0][i]] == i &&
lc.rmq.dp[0][lc.in[i]] == i);
assert(lc.tin[lc.rmq.dp[0][i]] == i &&
lc.rmq.dp[0][lc.tin[i]] == i);
}
int q;
cin >> q;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#define PROBLEM "https://judge.yosupo.jp/problem/lca"
#include "../template.hpp"
#include "../../../library/monotonic_stack/monotonic_stack.hpp"
#include "../../../library/trees/tree_lift/tree_lift.hpp"
#include "../../../library/trees/tree_lift.hpp"
#include "../../../library/trees/linear_lca.hpp"
#include "../../../library/trees/lca_rmq/lca_rmq.hpp"
#include "../../../library/trees/lca_rmq.hpp"
#include "../compress_tree_asserts.hpp"
int main() {
cin.tie(0)->sync_with_stdio(0);
Expand All @@ -24,8 +23,8 @@ int main() {
assert(lc.lca(i, i) == i);
assert(lc.in_subtree(i, i));
assert(lin_lca.lca(i, i) == i);
assert(lc.in[lc.rmq.dp[0][i]] == i &&
lc.rmq.dp[0][lc.in[i]] == i);
assert(lc.tin[lc.rmq.dp[0][i]] == i &&
lc.rmq.dp[0][lc.tin[i]] == i);
}
while (q--) {
int u, v;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// as std::map insert takes O(n) time in debug mode
#undef _GLIBCXX_DEBUG
#include "../template.hpp"
#include "../../../library/trees/subtree_isomorphism.hpp"
#include "../../../library/trees/uncommon/subtree_isomorphism.hpp"
int main() {
cin.tie(0)->sync_with_stdio(0);
int n;
Expand Down
Loading