检查你的 Tarjan() 中用于标记是否在栈内的数组 flag 的下标有没有混用节点的时间戳和编号。
Tarjan()
flag
如:
void Tarjan(int x){ //... flag[x]=true; //... if(dfn[x]==low[x]){ build.n++; while(s[top]!=x){ flag[s[top]]=false;//将这里写成top而不是s[top]就是错的 //... }flag[s[top]]=false;//同理 //... } }