EIMINHTR - MINIMUM TREE HEIGHT
Xem dạng PDF
Gửi bài giải
Điểm:
1,00 (OI)
Giới hạn thời gian:
1.0s
Giới hạn bộ nhớ:
256M
Input:
stdin
Output:
stdout
Nguồn bài:
Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch
Given a tree of ~N~ nodes labeled from ~0~ to ~N - 1~, find out the minimum rooted tree among possible rooted trees
Input
- The first line is an integer ~N~ ~(1 \le N \le 10^5)~.
- Each line among the next ~N - 1~ lines contain ~2~ integers ~u, v~, the connecting edge between vertex ~u~ and vertex ~v~.
Output
- Print out the root node and the minimum tree height. If there are more than one possible root, print out the minimum node.
-
Sample Input
7
0 1
1 2
2 3
3 5
3 4
4 6
Sammple Output
2 3
Bình luận