Skip to content

Commit dd7dcf8

Browse files
lrvideckisweb-flow
andauthored
reorg of trees folder (#154)
* initial reorg * [auto-verifier] verify commit 63c5a61 * move include so it works on main branch * compile fixes * format now * fix * more fixes * remove include * fix cpp check --------- Co-authored-by: GitHub <[email protected]>
1 parent 639a238 commit dd7dcf8

29 files changed

+40
-98
lines changed

.verify-helper/timestamps.remote.json

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@
6767
"tests/library_checker_aizu_tests/graphs/strongly_connected_components_aizu.test.cpp": "2025-08-04 17:01:28 -0600",
6868
"tests/library_checker_aizu_tests/graphs/strongly_connected_components_lib_checker.test.cpp": "2025-08-04 17:01:28 -0600",
6969
"tests/library_checker_aizu_tests/graphs/two_edge_components.test.cpp": "2025-08-04 17:01:28 -0600",
70-
"tests/library_checker_aizu_tests/handmade_tests/count_paths.test.cpp": "2025-08-05 15:52:46 -0600",
7170
"tests/library_checker_aizu_tests/handmade_tests/dsu_size.test.cpp": "2024-12-14 19:50:29 -0600",
7271
"tests/library_checker_aizu_tests/handmade_tests/edge_cd_small_trees.test.cpp": "2025-04-27 21:47:37 -0600",
7372
"tests/library_checker_aizu_tests/handmade_tests/fib_matrix_expo.test.cpp": "2024-12-14 19:50:29 -0600",
@@ -126,15 +125,4 @@
126125
"tests/library_checker_aizu_tests/strings/suffix_array_short.test.cpp": "2025-08-05 19:19:23 -0600",
127126
"tests/library_checker_aizu_tests/strings/trie.test.cpp": "2024-12-05 10:41:42 -0600",
128127
"tests/library_checker_aizu_tests/strings/wildcard_pattern_matching.test.cpp": "2025-08-05 19:19:23 -0600",
129-
"tests/library_checker_aizu_tests/trees/count_paths_per_length.test.cpp": "2025-08-05 15:52:46 -0600",
130-
"tests/library_checker_aizu_tests/trees/edge_cd_contour_range_query.test.cpp": "2025-04-27 21:47:37 -0600",
131-
"tests/library_checker_aizu_tests/trees/edge_cd_contour_range_update.test.cpp": "2025-04-27 21:47:37 -0600",
132-
"tests/library_checker_aizu_tests/trees/edge_cd_count_paths_per_length.test.cpp": "2025-04-27 21:47:37 -0600",
133-
"tests/library_checker_aizu_tests/trees/edge_cd_reroot_dp.test.cpp": "2025-04-27 21:47:37 -0600",
134-
"tests/library_checker_aizu_tests/trees/kth_path_ladder.test.cpp": "2025-08-06 11:58:12 -0600",
135-
"tests/library_checker_aizu_tests/trees/kth_path_linear.test.cpp": "2025-08-06 11:58:12 -0600",
136-
"tests/library_checker_aizu_tests/trees/kth_path_tree_lift.test.cpp": "2025-08-05 15:52:46 -0600",
137-
"tests/library_checker_aizu_tests/trees/lca_all_methods_aizu.test.cpp": "2025-08-06 09:59:41 -0600",
138-
"tests/library_checker_aizu_tests/trees/lca_all_methods_lib_checker.test.cpp": "2025-08-06 09:59:41 -0600",
139-
"tests/library_checker_aizu_tests/trees/subtree_isomorphism.test.cpp": "2025-08-05 18:22:08 -0600"
140128
}

library/trees/centroid_decomp_uncommon/count_paths_per_length.hpp

Lines changed: 0 additions & 44 deletions
This file was deleted.
File renamed without changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
//! returns 1 if v is in u's subtree
22
bool in_subtree(int u, int v) {
3-
return in[u] <= in[v] && in[v] < in[u] + siz[u];
3+
return tin[u] <= tin[v] && tin[v] < tin[u] + siz[u];
44
}

library/trees/lca_rmq/next_on_path.hpp renamed to library/trees/extra_members/next_on_path.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
//! @space O(1)
66
int next_on_path(int u, int v) {
77
assert(u != v);
8-
return in_subtree(u, v) ? rmq.query(in[u] + 1, in[v] + 1)
9-
: p[u];
8+
return in_subtree(u, v)
9+
? rmq.query(tin[u] + 1, tin[v] + 1)
10+
: p[u];
1011
}

library/trees/extra_members/compress_tree.hpp renamed to library/trees/extra_members/virtual_tree.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#include "../../monotonic_stack/monotonic_stack.hpp"
21
//! https://github.com/kth-competitive-programming/kactl/blob/main/content/graph/CompressTree.h
32
//! @code
43
//! vector<vi> adj(n);
@@ -11,7 +10,7 @@
1110
//! @time O(|subset| log |subset|)
1211
//! @space O(|subset|)
1312
array<vi, 2> compress_tree(vi subset) {
14-
auto proj = [&](int v) { return in[v]; };
13+
auto proj = [&](int v) { return tin[v]; };
1514
ranges::sort(subset, {}, proj);
1615
int len = sz(subset);
1716
rep(i, 1, len)

library/trees/lca_rmq/lca_rmq.hpp renamed to library/trees/lca_rmq.hpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#pragma once
2-
#include "../../data_structures/rmq.hpp"
2+
#include "../monotonic_stack/monotonic_stack.hpp"
3+
#include "../data_structures/rmq.hpp"
34
//! https://github.com/kth-competitive-programming/kactl/blob/main/content/graph/LCA.h
45
//! @code
56
//! {
@@ -14,13 +15,13 @@
1415
// NOLINTNEXTLINE(readability-identifier-naming)
1516
struct LCA {
1617
int n;
17-
vi in, siz, d, p;
18+
vi tin, siz, d, p;
1819
RMQ<int, function<int(int, int)>> rmq = {{}, NULL};
1920
LCA(const auto& adj):
20-
n(sz(adj)), in(n), siz(n, 1), d(n), p(n) {
21+
n(sz(adj)), tin(n), siz(n, 1), d(n), p(n) {
2122
vi order;
2223
auto dfs = [&](auto&& self, int v) -> void {
23-
in[v] = sz(order), order.push_back(v);
24+
tin[v] = sz(order), order.push_back(v);
2425
for (int u : adj[v])
2526
if (u != p[v])
2627
d[u] = d[p[u] = v] + 1, self(self, u),
@@ -32,12 +33,12 @@ struct LCA {
3233
}
3334
int lca(int u, int v) {
3435
if (u == v) return u;
35-
auto [x, y] = minmax(in[u], in[v]);
36+
auto [x, y] = minmax(tin[u], tin[v]);
3637
return p[rmq.query(x + 1, y + 1)];
3738
}
38-
#include "../extra_members/dist_edges.hpp"
39-
#include "../extra_members/in_subtree.hpp"
40-
#include "../extra_members/on_path.hpp"
41-
#include "next_on_path.hpp"
42-
#include "../extra_members/compress_tree.hpp"
39+
#include "extra_members/dist.hpp"
40+
#include "extra_members/in_subtree.hpp"
41+
#include "extra_members/on_path.hpp"
42+
#include "extra_members/next_on_path.hpp"
43+
#include "extra_members/virtual_tree.hpp"
4344
};

library/trees/linear_lca.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,5 @@ struct linear_lca {
4141
}
4242
return d[u] < d[v] ? u : v;
4343
}
44-
#include "extra_members/dist_edges.hpp"
44+
#include "extra_members/dist.hpp"
4545
};

library/trees/tree_lift/tree_lift.hpp renamed to library/trees/tree_lift.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@ struct tree_lift {
3737
else u = p[u], v = p[v];
3838
return u;
3939
}
40-
#include "../extra_members/dist_edges.hpp"
40+
#include "extra_members/dist.hpp"
4141
};

0 commit comments

Comments
 (0)