Good afternoon! Recently I faced the following problem: given k trees on n vertices, let p[i](a, b) be the distance from vertex a to vertex b in the i-th tree. It is necessary to find two vertices x and y such that p[0](x, y) + ... + p[k-1](x, y) is minimal (i.e. choose a pair of points such that the sum of the distances from one to the other across all trees will be minimal). As I understood, it is necessary to use centroid decomposition for the solution, but I don't quite understand how to apply it here :( The trees are unweighted, they can have different shapes. 1 <= k <= 1000, 2 <= n <= 5e5, n * k <= 1e6. If you have any ideas, write them in the comments. Thank you in advance!




