QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#22396. Earthquake Damage 2

Statistics

Wisconsin has had an earthquake that has struck Farmer John's farm! The earthquake has damaged some of the pastures so that they are unpassable. Remarkably, none of the cowpaths was damaged.

As usual, the farm is modeled as a set of $P$ ($1 \le P \le 3,000$) pastures conveniently numbered $1..P$ which are connected by a set of $C$ ($1 \le C \le 20,000$) non-directional cowpaths conveniently numbered $1..C$. Cowpath $i$ connects pastures $a_{i}$ and $b_{i}$ ($1 \le a_{i} \le P; 1 \le b_{i} \le P$). Cowpaths might connect $a_{i}$ to itself or perhaps might connect two pastures more than once. The barn is located in pasture 1.

A total of $N$ ($1 \le N \le P$) cows (in different pastures) sequentially contacts Farmer John via moobile phone with an integer message $report_{j}$ ($2 \le report_{j} \le P$) that indicates that pasture $report_{j}$ is undamaged but that the calling cow is unable to return to the barn from pasture $report_{j}$ because she could not find a path that does not go through damaged pastures.

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

Input

  • Line 1: Three space-separated integers: $P$, $C$, and $N$
  • Lines $2..C+1$: Line $i+1$ describes cowpath $i$ with two integers: $a_{i}$ and $b_{i}$
  • Lines $C+2..C+N+1$: Line $C+1$+$j$ contains a single integer: $report_{j}$

Output

  • Line 1: One number, the minimum number of damaged pastures.

Examples

Input 1

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

Output 1

1

Only pasture 2 being damaged gives such a scenario.

Problem credits: Hal Burch, Richard Peng, 2008

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.