Skip to content

Commit fd08cc1

Browse files
committed
Fix
1 parent f5011ab commit fd08cc1

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

cp-algo/tree/hld.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ namespace cp_algo::graph {
3030
}
3131
par[root] = up[root] = root;
3232
for(auto v: topsort | std::views::reverse) {
33+
if (size[v] == 1) continue;
3334
node_index big = -1;
3435
for(auto e: g.outgoing(v)) {
3536
auto u = g.edge(e).traverse(v);
@@ -38,7 +39,7 @@ namespace cp_algo::graph {
3839
big = u;
3940
}
4041
}
41-
int t = in[v] + (big == -1 ? 0 : size[big]);
42+
int t = in[v] + size[big];
4243
for(auto e: g.outgoing(v)) {
4344
auto u = g.edge(e).traverse(v);
4445
if (size[u] > size[v]) continue;

0 commit comments

Comments
 (0)