Tree //2010 ACM-ICPC Multi-University Training Contest(10)——Host by HEU

来源:互联网 发布:淘宝开店经验心得分享 编辑:程序博客网 时间:2024/05/09 05:16

Tree

Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other)
Total Submission(s) : 17   Accepted Submission(s) : 5

Font: Times New Roman | Verdana | Georgia

Font Size:

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

41 2 1002 3 502 4 5041 2 1002 3 503 4 50

Sample Output

150 2200 1

Source

2010 ACM-ICPC Multi-University Training Contest(10)——Host by HEU
无奈,自己的代码没保存、、、、、、
原创粉丝点击