Submit | All submissions | Best solutions | Back to list |
EITREHE1 - Tree height |
Given a tree with N nodes which are numbered from 0 to N-1. Root of tree is node numbered by 0. Caculate height of the tree.
Input
The first line is an integer N (1 <= N <= 10 ^ 5).
Each line in the next N - 1 lines contains 2 integers u v, represeting an edge connecting vertex u and vertex v.
Output:
An integer which is height of the given tree.
Input:
3
0 1
1 2
Output:
2
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 |