Submit | All submissions | Best solutions | Back to list |
EIMAXHTR - The highest tree |
Given a tree N vertices, numbered from 0-to N-1. Find the vertex with the smallest index such that the height of the tree is greatest if the vertex with the smallest is root
Input
The first line is an integer N (1 <= N <= 10 ^ 5).
The next N - 1 lines contain 2 integers u v, the connecting edge between vertex u and vertex v.
Output
Print the vertex and maximum height
Example
Input: 3 0 1 1 2 Output: 0 2
Input: 4 0 1 0 2 2 3 Output: 1 3
Added by: | Ha Minh Ngoc |
Date: | 2016-01-04 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | CSHARP C++ 4.3.2 CPP CPP14 CPP14-CLANG FSHARP GO JAVA JS-MONKEY NODEJS PHP PYTHON PYPY PYPY3 PYTHON3 RUBY SQLITE SWIFT VB.NET |