无根树转有根树

Posted -ackerman

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了无根树转有根树相关的知识,希望对你有一定的参考价值。

std::vector<int> tree[maxn];
int fa[maxn];

void dfs(int u,int father) {
    int len = tree[u].size();
    for (int i = 0;i < len;i++) {
        int v = tree[u][i];
        if (v != father)
            dfs(v,fa[v] = u);
    }
}

以上是关于无根树转有根树的主要内容,如果未能解决你的问题,请参考以下文章

蓝桥杯 结点选择

JSOI2012越狱老虎桥

#1542 : 无根数变有根树

有无标号计数

以 BZOJ 2002 为例学习有根树LCT(Link-Cut Tree)

树的重心