链接:http://agc001.contest.atcoder.jp/tasks/agc001_c
题解(官方):
We use the following well-known fact about trees.Let T be a tree, and let D be the diameter of the tree.
• If D is even, th...
有负边权,所以用树形DP来找树的直径。
1 //树形DP求树的直径
2 #include<bits/stdc++.h>
3 using namespace std;
4 const int N=500005,M=500005;
5 int n,m,tot,ans;
6 int f1[N],f2[N];//以u为根...