树的重心
int sz[N],mins = 1e9,rt;
void dfs(int u,int fa) {
sz[u] = 1; int maxs = 0;
for(int i = head[u]; i;i = e[i].nxt) {
int v = e[i].v; if(v == fa) continue;
dfs(v,u);
sz[u] += sz[v];
if(maxs < sz[v]) maxs = sz[v];
}
maxs = max(maxs,n-sz[u]);
if(maxs < mins) mins = maxs,rt = u;
}