We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 607f3cf commit 673622fCopy full SHA for 673622f
library/trees/edge_cd.hpp
@@ -37,9 +37,9 @@ template<class F, class G> struct edge_cd {
37
if (cent != -1) return cent;
38
siz[v] += siz[u];
39
}
40
- if (p == -1) return v;
41
- return 2 * siz[v] > m ? siz[p] = m + 1 - siz[v],
42
- v : -1;
+ return 2 * siz[v] > m
+ ? p >= 0 && (siz[p] = m + 1 - siz[v]),
+ v : -1;
43
44
void dfs(int v, int m) {
45
if (m < 2) return;
0 commit comments