#P4342. CF348 Pilgrims

CF348 Pilgrims

Pilgrims

题面翻译

很久很久以前,有一块叫做Dudeland的土地,由n1n-1条双向道路和nn座城镇构成。从任何一个城镇出发都能到达其他所有城镇。Dudeland有mm座城市有修道院,每座修道院里住着一名朝圣者。

年初,每座修道院的朝圣者都会列出离他所在城镇最远的修道院,如果有多个,就全部写下来。当Big Lebowski Day来临的时候,所有的朝圣者就会步行去往任意一个他列出来的修道院。

Walter讨厌朝圣者,所以他将摧毁一座没有修道院的城镇,这座城镇就无法通行了。Walter想知道,摧毁哪座城镇,可以让尽可能多的朝圣者无法到达任何一个他写下的目的地,并求出有多少朝圣者无法到达。

题目描述

A long time ago there was a land called Dudeland. Dudeland consisted of n n towns connected with n1 n-1 bidirectonal roads. The towns are indexed from 1 1 to n n and one can reach any city from any other city if he moves along the roads of the country. There are m m monasteries in Dudeland located in m m different towns. In each monastery lives a pilgrim.

At the beginning of the year, each pilgrim writes down which monastery is the farthest from the monastery he is living in. If there is more than one farthest monastery, he lists all of them. On the Big Lebowski day each pilgrim picks one town from his paper at random and starts walking to that town.

Walter hates pilgrims and wants to make as many of them unhappy as possible by preventing them from finishing their journey. He plans to destroy exactly one town that does not contain a monastery. A pilgrim becomes unhappy if all monasteries in his list become unreachable from the monastery he is living in.

You need to find the maximum number of pilgrims Walter can make unhappy. Also find the number of ways he can make this maximal number of pilgrims unhappy: the number of possible towns he can destroy.

输入格式

The first line contains two integers n n ( 3<=n<=105 3<=n<=10^{5} ) and m m ( 2<=m&lt;n ). The next line contains m m distinct integers representing indices of towns that contain monasteries.

Next n1 n-1 lines contain three integers each, ai a_{i} , bi b_{i} , ci c_{i} , indicating that there is an edge between towns ai a_{i} and bi b_{i} of length ci c_{i} ( 1<=ai,bi<=n,1<=ci<=1000,aibi 1<=a_{i},b_{i}<=n,1<=c_{i}<=1000,a_{i}≠b_{i} ).

输出格式

Output two integers: the maximum number of pilgrims Walter can make unhappy and the number of ways in which he can make his plan come true.

样例 #1

样例输入 #1

8 5
7 2 5 4 8
1 2 1
2 3 2
1 4 1
4 5 2
1 6 1
6 7 8
6 8 10

样例输出 #1

5 1