Choosing Capital for Treeland
题意翻译
### 题目描述
Treeland 国有 $n$ 个城市,有些城市间存在 **单向** 道路。这个国家一共有 $n - 1$ 条路。我们知道,如果把边视作双向的,那么从任意城市出发能到达任意城市。
城市的委员会最近决定为 Treeland 国选择一个首都,显然首都会是国中的一个城市。委员会将在首都开会,并经常取其他城市(这里不考虑从其他城市回到首都)。因此,如果城市 $a$ 被选为首都,那么所有的道路应该被定向,以使得我们能从城市 $a$ 到达其他城市。所以,有些路可能需要反转方向。
帮助委员会选择首都使得他们需要反转道路的次数最小。
### 输入格式
第一行有一个整数 $n$($2 \le n \le 2 \times 10^5$),表示城市的数量。
接下来 $n- 1$ 行描述道路,每个道路一行,用一对整数 $s_i,t_i$($1 \le s_i,t_i\le n$,$s_i \ne t_i$)表示该道路连接的两个城市,第 $i$ 条道路的方向是从城市 $s_i$ 到城市 $t_i$。
你可以认为 Treeland 国的城市被编号为 $1$ 到 $n$。
### 输出格式
第一行输出需要反转的道路数量的最小值。第二行输出所有可能的选择首都的方式,你需要以从小到大的顺序输出所有可能的城市编号。
Translated by uid $408071$.
题目描述
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<=n<=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<=s_{i},t_{i}<=n; s_{i}≠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