2020.01.16 [group] simulation provincial election

This game is currently only a change out of the question.

 

T1: First, we find that for a k-th key tree configuration, most answer must be 2 * sum-maxdis, which represents the sum of all edge weights and, maxdis represents the length of the diameter. I know after this we can calculate the answer in two parts.

First, calculate the sum. We enumerate each side, and then calculate an edge which may occur in a few key programs trees. This side edge is provided with a key point x, y on the other side there is a critical point (obviously x + y = m), then this edge is present in the number of achievements off scheme is C (m, k) - C (x, k) -C (y, k).

Then calculated maxdis, we enumerate two key points u, v, u ~ v is calculated and then this program chain number becomes diameter. This is what we have to enumerate a few other key points, determine what other key points can occur in off u ~ v achievements of this diameter. The method is specific for a key x, if dis [x] [u] <dis [u] [v] and dis [x] [v] <dis [u] [v] then x is legal. Note that a key may be multiple tree diameter, we take the smallest number one, in determining the legality of x length of time if the two chains are equal then we will compare their numbers.

Assuming now that for a set of u, v s have a legitimate s, then this group u, v is the number of programs as the diameter of C (s, k-2).

So far we have completed two parts of the calculation. When seeking the distance between the two key points that we can use the idea of ​​a virtual tree to find.

 

T2: problem solution be updated.

 

T3: problem solution be updated.

Published 149 original articles · won praise 24 · views 10000 +

Guess you like

Origin blog.csdn.net/chiyankuan/article/details/104025172