Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

做的不是很爽~~ 贴一下

Posted by snoopyII at 2011-09-22 18:51:53 on Problem 3659
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator