传送门:点击打开链接
题意:找到树的重心,要求平衡点相同时编号越小越好
树重心是一个非常重要的东西,在树的分治中占有一席之地,能使树的分治的复杂度不会退化到O(n^2),是一种十分有效的手段
树的重心的定义:将某一点删除,一颗树会分成许多棵子树,。一个树T的重心就是,删除了重心后,得到的那些子树中的最大子树的点数是最小的
求法是利用树型dp的思路,很容易实现
#include<map>
#include<set>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<cctype>
#include<string>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
#define fuck printf("fuck")
#define FIN freopen("input.txt","r",stdin)
#define FOUT freopen("output.txt","w+",stdout)
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;const int MX = 2000