Problem
Choosing Capital for Treeland
Description
The country Treeland consists of n cities, some pairs of them are connected with unidirectional roads. Overall there are 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.
Input
The first input line contains integer — the number of cities in Treeland. Next lines contain the descriptions of the roads, one road per line. A road is described by a pair of integers — the numbers of cities, connected by that road. The road is oriented from city to city . You can consider cities in Treeland indexed from to .
Output
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.
Example
Input #1
1  3 
Output #1
1  0 
Input #2
1  4 
Output #2
1  2 
标签：树形DP
Translation
给出一棵由有向边组成的树，要求选一个点使得最小化从它到其余所有点的路径中反向边的条数之和。
Solution
首先转化问题为：给出一棵由无向边组成的树，边有权值或(为正向，为反向)，要求找一个点使得最小化其到所有点的路径的权值和。特别地，计算某个点时，此点到其父结点的边的边权要异或。
第一次，定下每边权值，并出每个点的子树的总权值。
第二次，按序计算答案。对于每个点，，其中为其父结点，为其到父结点的边的边权。
Code
1 
