shunfurh
编程介的小学生
2017-11-05 04:16

Tree

  • lines
  • class
  • each
  • 结构

Problem Description
In the Data structure class of HEU, the teacher asks one problem: How to find the longest path of one tree and the number of such longest path?

Input
There are several test cases. The first line of each case contains only one integer N, means there are N nodes in the tree. N-1 lines follow, each line has three integers w,v and len, indicate that there is one edge between node w and v., and the length of the edge is len.

Output
For each test case, output the length of longest path and its number in one line.

Sample Input
4
1 2 100
2 3 50
2 4 50
4
1 2 100
2 3 50
3 4 50

Sample Output
150 2
200 1

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答

为你推荐

换一换