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 |
做的不是很爽~~ 贴一下procedure dfs(i:longint); var j:longint;ff,done:boolean;yb,fb:longint; begin u[i]:=false; yb:=maxlongint shr 1; j:=ad[i];ff:=false;done:=false; while j<>0 do begin if u[v[j]] then begin done:=true; dfs(v[j]); inc(f[i,0],min(min(f[v[j],1],f[v[j],0]),f[v[j],2])); if yb>f[v[j],0] then begin fb:=v[j];yb:=f[v[j],0];end; if min(f[v[j],0],f[v[j],1])=f[v[j],0] then ff:=true; inc(f[i,1],min(f[v[j],0],f[v[j],1])); inc(f[i,2],min(f[v[j],0],f[v[j],1])); end; j:=pre[j]; end; if not done then begin f[i,0]:=1; f[i,1]:=maxlongint shr 1; f[i,2]:=0; exit; end; if not ff then f[i,1]:=f[i,1]-f[fb,1]+f[fb,0]; inc(f[i,0]); end; Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator