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 |
纪念我第一个BCC啦啦啦啦找桥的算法是我自己根据严老数据结构的关键点算法自己改变的,找BCC的算法是我自己琢磨出来的。 呵呵,值得庆贺一下。 PKU很文明的,我努力克制自己发代码的欲望。不过就发一个dfs的过程吧。这是算法的精华,又是pascal,所以仅仅只能说是有参考价值。 procedure dfs(v0,u:longint); var i,min,k:longint; p:link; begin inc(clock); min:=clock; visited[v0]:=clock; push(v0); inc(times[v0]); p:=vertex[v0]; while p<>nil do begin if visited[p^.d]=0 then begin dfs(p^.d,v0); if low[p^.d]<min then min:=low[p^.d]; if low[p^.d]>visited[v0] then begin inc(total); while stack[top]<>v0 do begin k:=pop; color[k]:=total; dec(times[k]); end; end else begin inc(times[v0]); push(v0); end; end else if (p^.d<>u) and (visited[p^.d]<min) then min:=visited[p^.d]; p:=p^.next; end; low[v0]:=min; end; Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator