|
||||||||||
The diameter of graphTime Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 562 Accepted Submission(s): 134 Problem Description The graph diameter is the length of the "longest shortest path" between any two vertices of a graph. In other words, a graph's diameter is the longest path which must be traversed in order to travel from any vertex to another when paths which backtrack, detour, or loop are excluded from consideration. Given an undirected graph, your mission is to count the number of diameters of it. Input The input contains multiple test cases. For each test case, it contains n+1 lines. Line 1: two integers m, n (2<= m <= 100, 1 <= n <= 4000) indicating that there are m vertices and n edges in the city. Line 2~n+1: each contains three integers i, j, d (1 <= i, j <= m, 1 <= d <= 100), indicating that there is an edge of length d connecting vertex i and vertex j. Output Output the value of the diameter and the number of diameters in a single line, separated by a single space. Sample Input
Sample Output
Source | ||||||||||
|