| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
标程的错误原因猜想这是DFS的标准过程
anc数组就是low数组。
procedure dfs(i,p,dep:longint);
var tmp:pnode;
cnt:longint;
begin
col[i]:=1; d[i]:=dep;
anc[i]:=dep; cnt:=0;
tmp:=g[i];
while tmp<>nil do begin
if (col[tmp^.n]=1)and(tmp^.n<>p)and(anc[tmp^.n]<anc[i]) then anc[i]:=d[tmp^.n];【标程这里应该是写错成了anc[i]=anc[tmp^.n]】
if (col[tmp^.n]=0) then begin
inc(cnt); dfs(tmp^.n,i,dep+1);
if anc[tmp^.n]<anc[i] then anc[i]:=anc[tmp^.n];
if (i=root)and(cnt>1) then cut[i]:=true;
if (i<>root)and(anc[tmp^.n]>=d[i]) then cut[i]:=true;
end;
tmp:=tmp^.next;
end;
col[i]:=2;
end;
【ancestor数组记录应该是边而不是路径】
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator