CF348E.Pilgrims
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
A long time ago there was a land called Dudeland. Dudeland consisted of n towns connected with n−1 bidirectonal roads. The towns are indexed from 1 to n and one can reach any city from any other city if he moves along the roads of the country. There are m monasteries in Dudeland located in 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 ( 3<=n<=105 ) and m ( 2<=m<n ). The next line contains m distinct integers representing indices of towns that contain monasteries.
Next n−1 lines contain three integers each, ai , bi , ci , indicating that there is an edge between towns ai and bi of length ci ( 1<=ai,bi<=n,1<=ci<=1000,ai=bi ).
输出格式
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
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