6404: Battle Over Cities
[Creator : ]
Description
It is vitally important to have all the cities connected by highways in a war.
If a city is occupied by the enemy, all the highways from/toward that city are closed.
We must know immediately if we need to repair any other highways to keep the rest of the cities connected.
Given the map of cities which have all the remaining highways marked, you are supposed to tell the number of highways need to be repaired, quickly.
For example, if we have $3$ cities and $2$ highways connecting $city_1 \leftrightarrow city_2$ and $city_1 \leftrightarrow city_3$. Then if $city_1$ is occupied by the enemy, we must have $1$ highway repaired, that is the highway $city_2 \leftrightarrow city_3$.
给你 $1 \sim N$ 个城市,以及这些城市之间的高速公路,问,如果某个城市被敌军占领,需要修复多少条告诉公路,才能保证余下公路的连通性。
If a city is occupied by the enemy, all the highways from/toward that city are closed.
We must know immediately if we need to repair any other highways to keep the rest of the cities connected.
Given the map of cities which have all the remaining highways marked, you are supposed to tell the number of highways need to be repaired, quickly.
For example, if we have $3$ cities and $2$ highways connecting $city_1 \leftrightarrow city_2$ and $city_1 \leftrightarrow city_3$. Then if $city_1$ is occupied by the enemy, we must have $1$ highway repaired, that is the highway $city_2 \leftrightarrow city_3$.
给你 $1 \sim N$ 个城市,以及这些城市之间的高速公路,问,如果某个城市被敌军占领,需要修复多少条告诉公路,才能保证余下公路的连通性。
Input
Each input file contains one test case.
Each case starts with a line containing $3$ numbers $N\ (N<1,000),\ M,\ K$, which are the total number of cities, the number of remaining highways, and the number of cities to be checked, respectively.
Then $M$ lines follow, each describes a highway by $2$ integers, which are the numbers of the cities the highway connects. The cities are numbered from $1$ to $N$.
Finally there is a line containing $K$ numbers, which represent the cities we concern.
Each case starts with a line containing $3$ numbers $N\ (N<1,000),\ M,\ K$, which are the total number of cities, the number of remaining highways, and the number of cities to be checked, respectively.
Then $M$ lines follow, each describes a highway by $2$ integers, which are the numbers of the cities the highway connects. The cities are numbered from $1$ to $N$.
Finally there is a line containing $K$ numbers, which represent the cities we concern.
Output
For each of the $K$ cities, output in a line the number of highways need to be repaired if that city is lost.
Constraints
$1 \leq N \leq 1,000$
$1 \leq M \leq \frac{n*(n-1)}{2}$
$1 \leq K \leq N$
$1 \leq M \leq \frac{n*(n-1)}{2}$
$1 \leq K \leq N$
Sample 1 Input
3 2 3
1 2
1 3
1 2 3
Sample 1 Output
1
0
0