Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## 55，我的也是

Posted by ZJ75211 at 2017-02-01 17:44:39 on Problem 3107
In Reply To:神啊!!!!谁能告诉我为什么会Runtime Error Posted by:blackchaoxu at 2007-01-30 12:40:44
```#include<iostream>
#include<cstdio>
#include<cstring>

using namespace std;
int dp[50005],cnt;
struct edge{
int v,next;
}e[50005];
{
e[++cnt].v=v;
}
int n;
int an[50005];
int dfs(int u,int fa)
{
int ch=1,c;
{
int v=e[i].v;
if(v==fa) continue;
c=dfs(v,u);
ch+=c;
dp[u]=max(dp[u],c);
}
dp[u]=max(dp[u],n-ch);
return ch;
}
int main()
{

scanf("%d",&n);
int a,b;
for(int i=1;i<n;i++)
{
scanf("%d%d",&a,&b);
}
int aa=dfs(1,0);
int tot=0;
an[0]=0x3f3f3f;
for(int i=1;i<=n;i++)
{
if(an[0]==dp[i]) an[++tot]=i;
if(an[0]>dp[i]) an[0]=dp[i],tot=0,an[++tot]=i;

}
for(int i=1;i<=tot;i++)
printf("%d ",an[i]);

return 0;
}```

Followed by: