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

## 直接暴力可过

Posted by BriMon at 2018-07-04 10:38:52 on Problem 3107
```本来闲得无聊写个暴力...然后过了
#include <iostream>
#include <cstdio>
using namespace std;

int n;
struct edge
{
int nxt, to;
}ed[100010];
int siz[50010];
int f[50010];
int fat[50010];
int mx=1e9;

inline void dfs(int x, int fa)
{
siz[x] = 1;
for (register int i = head[x]; i; i = ed[i].nxt)
{
int to = ed[i].to;
if (fa == to) continue;
fat[to] = x;
dfs(to, x);
siz[x] += siz[to];
}
}

int main()
{
scanf("%d", &n);
for (register int i = 1; i < n; i++)
{
int x, y;
scanf("%d%d", &x, &y);
}
dfs(1, 0);
for (register int x = 1; x <= n; x ++)
{
int sum=0;
for (register int i = head[x]; i; i = ed[i].nxt)
{
int to = ed[i].to;
if (to == fat[x]) sum = max(sum, siz[1] - siz[x]);
else sum = max(sum, siz[to]);
}
f[x] = sum;
mx = min(mx, f[x]);
}
for (register int i = 1; i <= n; i ++)
{
if (f[i] == mx) printf("%d ", i);
}
return 0;
}```

Followed by: