求树的重心--经典

http://poj.org/problem?id=1655

求树的重心--经典_第1张图片

 

#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
typedef long long ll;
#define INF 0x3f3f3f3f
vector p[20001];
ll num[20001],maxx,n,point;
void dfs(ll u,ll fa){
	ll temp=-INF;
	num[u]=1;
	ll len=p[u].size();
	for(ll i=0;i>t;
	while(t--){
		memset(num,0,sizeof(num));
		ll x,y;
		cin>>n;
		for(ll i=1;i<=n;i++){
			p[i].clear();
		}
		for(ll i=1;i>x>>y;
			p[x].push_back(y);
			p[y].push_back(x);
		}
		maxx=INF;
		point=INF;
		dfs(1,-1);
		cout<

 

你可能感兴趣的:(树形dp,树的重心)