Tree Distance
Medium
Execution time limit is 6 seconds
Runtime memory usage limit is 256 megabytes
You are given an undirected tree T. Let S be the set of all integers x such that there exist two distinct leaves u and v in T satisfying d(u, v) = x. Here d(u, v) is the number of edges on the shortest path between u and v.
Find this set S.
Input
The first line of input contains one integer n (1 ≤ n ≤ 200000), the number of vertices in the tree. Each of the next n-1 lines contains two integers x and y (1 ≤ x, y ≤ n): the numbers of vertices connected by the corresponding edge. It is guaranteed that the resulting graph is a tree.
Output
On the first line, print the number of elements in S. After that, print all elements of S in ascending order, one per line.
Examples
Input #1
Answer #1
Submissions 97
Acceptance rate 12%