警示后人,19pts其他都RE
查看原帖
警示后人,19pts其他都RE
1015002
Charles_with_wkc楼主2025/8/29 22:16
void dfs2(int u,int f,int t){
	top[u]=t;
	ecnt++;
	w[ecnt]=a[u];
	dfn[u]=ecnt;
	if(wson[u]==0) return ;
	dfs2(wson[u],u,t);
	for(int i=0;i<e[u].size();i++){
		if(e[u][i]==f||e[u][i]==u||wson[u]==e[u][i]) continue;
		dfs2(e[u][i],e[u][i],e[u][i]);
	}
	return ;
}

这个代码你肯定看不出来哪里有问题。这里

dfs2(e[u][i],e[u][i],e[u][i]);

我的父亲应该是 uu 而不应该重新改成 eu,ie_{u,i}

正确的写法应该是

void dfs2(int u,int f,int t){
	top[u]=t;
	ecnt++;
	w[ecnt]=a[u];
	dfn[u]=ecnt;
	if(wson[u]==0) return ;
	dfs2(wson[u],u,t);
	for(int i=0;i<e[u].size();i++){
		if(e[u][i]==f||e[u][i]==u||wson[u]==e[u][i]) continue;
		dfs2(e[u][i],u,e[u][i]);
	}
	return ;
}
2025/8/29 22:16
加载中...