1.

Distance between citiesMax. Marks: 100A country consists of N cities that are represented as a tree graph. A tree graph is an undirected acyclic graph.The leaders of the country decided to hold Q meetings. For the ith meeting, there are K, leaders in different cities. For each meeting, theleaders want to find a city such that the maximum distance between any of the K, cities and a selected city is minimum.Note: This city does not have to be a part of the K, cities.Your task is to determine the minimum of the maximum distances obtained between the K, cities and the selected city.Input format• First line: Two space separated integers N and Q• Next N - 1 lines Two space-separated integers u and v denoting an edge between u and v• Next 2 x Q lines:First line: K, denoting the number of nodes in the queryo Second line K, space-separated integers where X, is denoting the cities of this queryOutput format

Answer»

I SEND you ANSWER in few MINUTES



Discussion

No Comment Found