Responsive image

问题 1585 --Earthquake

1585: Earthquake

时间限制: 1 Sec  内存限制: 128 MB
提交: 1  解决: 1
[提交][状态][讨论版][命题人:]

题目描述

Wenchuan has had an earthquake that has struck a town.The earthquake has damaged some of the villages so that they are unpassable. Remarkably, none of  paths was damaged.

 

As usual, the town is modeled as a set of  P (1 <= P <= 3,000)  villages  conveniently numbered 1…P which are connected by a set of C (1 <= C <= 20,000) non-directional paths conveniently numbered 1...C.  path  i  connects village Ai and Bi. paths might connect Ai to itself or perhaps might connect two villages more than once.  The town government is located in village 1.

 

A total of  N (1 <= N <= P)  villages sequentially contacts  the town government via moobile phone with an integer message Vj (2 <= Vj <= P) that indicates that village Vj is undamaged , but the villagers is unable to return to the town government from village Vj , because they could not find a path that does not go through damaged  villages.

 

After all the villages report  in,  determine the minimum number of  villages that are damaged.

输入描述

The first line of input gives a single integer, 1 ≤ T ≤ 10,  the number of test cases. Then follow, for each test case

* Line 1:             Three space-separated integers: P, C, and N

* Lines 2…C+1:       Line i+1 describes path i with two integers: Ai  and Bi

* Lines C+2…C+N+1:  Line C+1+j contains a single integer: Vj

输出描述

Output for each test case , a single line with a integer  K , the minimum number of damaged  villages.

样例输入

1
5 5 2
1 2
2 3
3 5
2 4
4 5
4
5

样例输出

1

来源

[提交][状态]
ACM算法攻关部