Skip to content

Commit 40a6294

Browse files
committed
more fixes
1 parent 7bdfc78 commit 40a6294

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

library/trees/linear_kth_path.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#pragma once
22
#include "linear_lca.hpp"
33
#include "ladder_decomposition/linear_kth_par.hpp"
4-
struct linear_kth_path {
5-
linear_lca lin_lca;
6-
linear_kth_par lin_kp;
7-
linear_kth_path(const vector<vi>& adj):
4+
template<class G> struct linear_kth_path {
5+
linear_lca<G> lin_lca;
6+
linear_kth_par<G> lin_kp;
7+
linear_kth_path(const G& adj):
88
lin_lca(adj), lin_kp(adj) {}
99
//! @param u,v endpoint nodes of path
1010
//! @param k index into path

library/trees/linear_lca.hpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
#pragma once
22
//! https://codeforces.com/blog/entry/125371
3+
//! @code
4+
//! vector<vi> adj(n);
5+
//! linear_lca llca(adj);
6+
//! vector<basic_string<int>> adj1(n);
7+
//! linear_lca llca1(adj1);
8+
//! @endcode
39
//! @time O(n + q)
410
//! @space O(n)
5-
struct linear_lca {
11+
template<class G> struct linear_lca {
612
struct node {
713
int d, label, asc;
814
};
915
vector<node> t;
1016
vi head;
11-
linear_lca(const vector<vi>& adj):
12-
t(sz(adj)), head(sz(t) + 1) {
17+
linear_lca(const G& adj): t(sz(adj)), head(sz(t) + 1) {
1318
vector<pii> order;
1419
auto dfs = [&](auto&& self, int v, int p) -> void {
1520
order.emplace_back(v, p);

tests/library_checker_aizu_tests/compress_tree_asserts.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#undef LCA
77
#include "../../library/contest/random.hpp"
88
void compress_tree_asserts(vector<vector<int>> adj,
9-
LCA& lc_rm) {
9+
LCA<vector<vi>>& lc_rm) {
1010
int n = sz(adj);
1111
vector<bool> used(n);
1212
KACTL_LCA kactl_lca(adj);

tests/library_checker_aizu_tests/trees/kth_node_on_path.test.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"https://judge.yosupo.jp/problem/jump_on_tree"
33
#include "../template.hpp"
44
#include "../../../library/contest/random.hpp"
5-
#include "../../../library/monotonic_stack/monotonic_stack.hpp"
65
#include "../../../library/trees/tree_lift/tree_lift.hpp"
76
#include "../../../library/trees/lca_rmq/lca_rmq.hpp"
87
#include "../../../library/trees/linear_lca.hpp"
@@ -12,7 +11,7 @@ int main() {
1211
cin.tie(0)->sync_with_stdio(0);
1312
int n, q;
1413
cin >> n >> q;
15-
vector<vector<int>> adj(n);
14+
vector<vi> adj(n);
1615
for (int i = 0; i < n - 1; i++) {
1716
int u, v;
1817
cin >> u >> v;

0 commit comments

Comments
 (0)