题目描述
PT07Z - Longest path in a tree
题目描述
You are given an unweighted, undirected tree. Write a program to output the length of the longest path (from one node to another) in that tree. The length of a path in this case is number of edges we traverse from source to destination.
输入格式
The first line of the input file contains one integer --- number of nodes in the tree (). Next lines contain edges of that tree --- Each line contains a pair means there is an edge between node and node .
输出格式
Print the length of the longest path on one line.
输入样例 #1
3
1 2
2 3
输出样例 #1
2
输入样例 #2
3
1 2
2 3
输出样例 #2
2
输入样例 #3
3
1 2
2 3
输出样例 #3
2
数据范围
The first line of the input file contains one integer --- number of nodes in the tree (). Next lines contain edges of that tree --- Each line contains a pair means there is an edge between node and node .