#t459. 找树根和孩子
找树根和孩子
The Tree Root and Its Children
Problem Background
Special for beginners, ^_^
Problem Description
Given a tree, output its root root, the node max with the most children, and that node's children.
Input Format
The first line: (number of nodes ), (number of edges ).
The following lines each contain two nodes and , meaning is a child of ().
Output Format
The first line: the tree root: root.
The second line: the node max with the most children.
The third line: max's children.
Sample Input
8 7
4 1
4 2
1 3
1 5
2 6
2 7
2 8
Sample Output
4
2
6 7 8
Constraints
.
Time limit s, memory KiB per test case.
Hint
- The root is the only node that is never listed as a child (no parent edge points to it).
- Build the child lists, then the node whose list is longest is
max.