虚树

https://blog.csdn.net/weixin_37517391/article/details/82744605

void insert(int u){
    if(top <= 1) {stk[++top] = u;return ;}
    int lca = LCA(u,stk[top]);
    if(lca == stk[top]) {stk[++top] = u;return ;}
    while(top > 1 && dfn[lca] <= stk[top-1]) {
        addedge(stk[top-1],stk[top]);
        --top;
    }
    if(lca != stk[top]) stk[++top] = lca;
    stk[++top] = u;
}

 

上一篇:Ganglia安装扩容


下一篇:【offerMe--面经必备】---快手面经分享(包含答案)