网络赛前10奖励计蒜客的本子或鼠标垫(外校也可以来现场领取)
Xidian Online Judge WebBoard
[ New Thread ]
Problem 1104 >> 怀疑数据里面有环,或者有其它不合法的情况
Alice @ 2017-04-18 16:01:53
[ Quote ] [ Edit ] [ Delete ] 1#
int ans;
void dfs(int u,int p) {
++ans;
for(int i=head[u];i!=-1;i=e[i].next) {
if(e[i].v==p) continue;
dfs(e[i].v,u);
}
}
这个dfs竟然会报运行错误
void dfs(int u,int p) {
++ans;
vis[u]=1;
for(int i=head[u];i!=-1;i=e[i].next) {
if(e[i].v==p) continue;
if(vis[e[i].v]) continue;
dfs(e[i].v,u);
}
}
然后如果我给每个点加了个vis访问标记就变成wa了
[Top] [Previous Page] [Next Page]
Anything about the Problems, Please Contact Admin:admin
All Copyright Reserved 2010-2014 Xidian ACM Online Judge TEAM
GPL2.0 2003-2014 HUSTOJ Project TEAM