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

树归难道不比两次BFS好?为什么大家都用两遍BFS

Posted by moretimes at 2013-04-10 09:34:05 on Problem 1985
inline void DFS (int x, int fa)
{
	for (int i = head[x]; ~ i; i = next[i])
	{
		if (key[i] == fa) continue;
		DFS (key[i], x);
		ans = max (ans, d[x] + len[i] + d[key[i]]);
		d[x] = max (d[x], d[key[i]] + len[i]);
	}
}

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