tarjan割点

vector<int> edges[N];
int n,m,cut[N],tot,low[N],dfn[N];
void tarjan(int u,int root){
    dfn[u]=low[u]=++tot;
    int child=0;
    for(int &v:edges[u]){
        if(!dfn[v]){
            tarjan(v,root);
            low[u]=min(low[u],low[v]);
            if(low[v]>=dfn[u]){
                child++;
                if(u!=root||child>1)
                    cut[u]=true;
            }
        }
        else{
            low[u]=min(low[u],dfn[v]);
        }
    }
}
posted @ 2025-09-11 11:22  xdhking  阅读(9)  评论(0)    收藏  举报