Skip to content

Commit ca9154c

Browse files
committed
fix test
1 parent 5568c4b commit ca9154c

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

tree/centroid_decomposition.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ struct CentroidDecomposition {
1414
std::vector<int> is_alive;
1515
std::vector<int> subtree_size;
1616

17-
void decompose(int r, int conn_size, auto callback) {
17+
template <class F> void decompose(int r, int conn_size, F callback) {
1818

1919
const int c = find_current_centroids(r, conn_size).first;
2020
is_alive.at(c) = 0;
@@ -69,7 +69,7 @@ struct CentroidDecomposition {
6969
return {c1, c2};
7070
}
7171

72-
void run(int r, auto callback) {
72+
template <class F> void run(int r, F callback) {
7373
int conn_size = 0;
7474

7575
auto rec = [&](auto &&self, int now, int prv) -> void {

tree/frequency_table_of_tree_distance.hpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,15 @@ struct frequency_table_of_tree_distance {
2222
}
2323
frequency_table_of_tree_distance(const std::vector<std::vector<int>> &to) {
2424
tos = to;
25-
cd = CentroidDecomposition(to).centroid_decomposition(0);
25+
26+
CentroidDecomposition c(to.size());
27+
for (int i = 0; i < int(to.size()); i++) {
28+
for (int j : to[i]) {
29+
if (i < j) c.add_edge(i, j);
30+
}
31+
}
32+
33+
cd = c.centroid_decomposition(0);
2634
}
2735
template <class S, std::vector<S> (*conv)(const std::vector<S> &, const std::vector<S> &)>
2836
std::vector<S> solve(const std::vector<S> &weight) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy