## Choosing Capital for Treeland

### 题目描述

The country Treeland consists of n cities, some pairs of them are connected with unidirectional roads. Overall there are $n-1$roads in the country. We know that if we don't take the direction of the roads into consideration, we can get from any city to any other one.

The council of the elders has recently decided to choose the capital of Treeland. Of course it should be a city of this country. The council is supposed to meet in the capital and regularly move from the capital to other cities (at this stage nobody is thinking about getting back to the capital from these cities). For that reason if city a is chosen a capital, then all roads must be oriented so that if we move along them, we can get from city a to any other city. For that some roads may have to be inversed.

Help the elders to choose the capital so that they have to inverse the minimum number of roads in the country.

### 输入格式

The first input line contains integer $n$ ($2$ $\le$ $n$ $\le$ $2*10^5$) — the number of cities in Treeland. Next $n-1$ lines contain the descriptions of the roads, one road per line. A road is described by a pair of integers $s_i,t_i$ ($1$ $\le$ $s_i,t_i$ $\le$ $n$;$s_i$ $\neq$ $t_i$) — the numbers of cities, connected by that road. The $i$-th road is oriented from city $s_i$ to city $t_i$. You can consider cities in Treeland indexed from $1$ to $n$.

### 输出格式

In the first line print the minimum number of roads to be inversed if the capital is chosen optimally. In the second line print all possible ways to choose the capital — a sequence of indexes of cities in the increasing order.

### 样例输入1

3
2 1
2 3


### 样例输出1

0
2


### 样例输入2

4
1 4
2 4
3 4


### 样例输出2

2
1 2 3


## 题解

upin[u]=upin[fa];
upin[u]+=ssin[fa]-ssin[u]-(!kfa[u]);
upin[u]+=kfa[u];
upout[u]=upout[fa];
upout[u]+=sout[fa]-sout[u]-kfa[u];
upout[u]+=(!kfa[u]);

$upin[u]$表示$u$上面朝向$u$的边数。
$upout[u]$表示$u$上面背向$u$的边数。
$ssin[u]$表示$u$下面朝向$u$的边数。
$sout[u]$表示$u$下面背向$u$的边数。
$kfa[u]$表示$u$连向父亲的边的方向。

#include<bits/stdc++.h>
using namespace std;
int n;
int u,v;
struct aa{
int to,nxt;
bool k;
}p;
int h,len=1;
p[++len].to=v;
p[len].k=k;
p[len].nxt=h[u];
h[u]=len;
}
bool kfa;
int fa;
int ssin,sout,upin,upout;
void dfs(int u,int fa){
for(int j=h[u];j;j=p[j].nxt){
if(p[j].to==fa) continue;
dfs(p[j].to,u);
ssin[u]+=ssin[p[j].to];
sout[u]+=sout[p[j].to];
kfa[p[j].to]=p[j].k;
if(p[j].k) sout[u]++;
else ssin[u]++;
}
}
void dfss(int u,int fa){
if(fa!=0){
upin[u]=upin[fa];
upin[u]+=ssin[fa]-ssin[u]-(!kfa[u]);
upin[u]+=kfa[u];
upout[u]=upout[fa];
upout[u]+=sout[fa]-sout[u]-kfa[u];
upout[u]+=(!kfa[u]);
}
for(int j=h[u];j;j=p[j].nxt){
if(p[j].to==fa) continue;
dfss(p[j].to,u);
}
}
int main(){
scanf("%d",&n);
for(int j=1;j<n;j++){
scanf("%d%d",&u,&v);
}