CF348E.Pilgrims

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

A long time ago there was a land called Dudeland. Dudeland consisted of nn towns connected with n1n-1 bidirectonal roads. The towns are indexed from 11 to nn and one can reach any city from any other city if he moves along the roads of the country. There are mm monasteries in Dudeland located in mm 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 nn ( 3<=n<=1053<=n<=10^{5} ) and mm ( 2<=m<n ). The next line contains mm distinct integers representing indices of towns that contain monasteries.

Next n1n-1 lines contain three integers each, aia_{i} , bib_{i} , cic_{i} , indicating that there is an edge between towns aia_{i} and bib_{i} of length cic_{i} ( 1<=ai,bi<=n,1<=ci<=1000,aibi1<=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

    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
    
首页