首页 > TAG信息列表 > POJ1655

POJ1655 Balancing Act (树的重心)

求树的重心的模板题,size[u]维护以u为根的子树大小,f[u]表示去掉u后的最大子树。 1 #include<cstdio> 2 #include<iostream> 3 #include<cstring> 4 using namespace std; 5 const int INF=0x7f7f7f7f; 6 const int N=20005; 7 int head[N],to[N*2],nxt[N*2],f[N],size[N];