We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f5011ab commit fd08cc1Copy full SHA for fd08cc1
cp-algo/tree/hld.hpp
@@ -30,6 +30,7 @@ namespace cp_algo::graph {
30
}
31
par[root] = up[root] = root;
32
for(auto v: topsort | std::views::reverse) {
33
+ if (size[v] == 1) continue;
34
node_index big = -1;
35
for(auto e: g.outgoing(v)) {
36
auto u = g.edge(e).traverse(v);
@@ -38,7 +39,7 @@ namespace cp_algo::graph {
38
39
big = u;
40
41
- int t = in[v] + (big == -1 ? 0 : size[big]);
42
+ int t = in[v] + size[big];
43
44
45
if (size[u] > size[v]) continue;
0 commit comments