There is a tree with n nodes and all the weight of edge is 1. So what’s the number of farthest distance point pairs.
5 1 2 2 3 3 4 4 5
1
For the sample input, there is only one farthest distance point pairs (node 1 and node 5), the distance is 4.
本站或者转载