• 2024-11-27tarjan[模板]
    强连通分量(有向图)voidtarjan(intx){ dfn[x]=low[x]=++cnt; stac[++top]=x; vis[x]=1; for(inti=hd[x];i;i=nxt[i]) { inty=go[i]; if(!dfn[y])//树边 {tarjan(y);low[x]=min(low[x],low[y]);} elseif(vis[y])low[x]=min(low[x],dfn[y]);//在栈中(判横叉边) }