| ||||||||||
| 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 | |||||||||
树归难道不比两次BFS好?为什么大家都用两遍BFSinline 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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator