시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 1024 MB | 19 | 7 | 7 | 43.750% |
Given a tree, calculate the average distance between two vertices in the tree. For example, the average distance between two vertices in the following tree is (d01 + d02 + d03 + d04 + d12 + d13 + d14 + d23 + d24 + d34)/10 = (6 + 3 + 7 + 9 + 9 + 13 + 15 + 10 + 12 + 2)/10 = 8.6.
Figure 1: The first sample case
On the first line an integer t (1 ≤ t ≤ 100): the number of test cases. Then for each test case:
For each testcase:
1 5 0 1 6 0 2 3 0 3 7 3 4 2
8.6