有向边tarjan
void tarjan(int u){ dfn[u]=low[u]=++num; stack[++top]=u; instack[u]=true; for(int i=hd[u];i;i=bl[i].nt){ if(!dfn[bl[i].to]){ tarjan(bl[i].to); low[u]=minn(low[u],low[bl[i].to]); } else if(instack[bl[i].to]) low[u]=minn(low[u],dfn[bl[i].to]); } if(dfn[u]==low[u]){ int tan=stack[top]; ++tot; while(tan!=u){ belong[tan]=tot; instack[tan]=false; tan=stack[--top]; } belong[tan]=tot; instack[tan]=false; } }