提示: 欢迎访问OurACM平台。
Problem 1844 Earthquake Damage

Accept: 41    Submit: 99
Time Limit: 1000 mSec    Memory Limit : 32768 KB

Problem Description

Open Source Tools help earthquake researchers stay a step ahead. Many geological research facilities around the world use or are in the process of developing open source software and applications designed to interpret and share information with other researchers. For example, OpenSees is an open source software framework for developing apps that help understand what happens to structures during and after earthquakes to help engineers design stronger buildings. Researchers are also using OpenSees to understand the potential ill-effects of seismic activity on viaducts and bridges.

China has had an earthquake that has struck Sichuan Province on Monday 12 May 2008!

The earthquake has damaged some of the cities so that they are unpassable. Remarkably, after repairing by Chinese People's Liberation Army, all the driveways between cities were fixed.

As usual, Sichuan Province is modeled as a set of P (1 <= P <= 3,000) cities conveniently numbered 1..P which are connected by a set of C (1 <= C <= 20,000) non-directional driveways conveniently numbered 1..C. Driveway i connects city a_i and b_i (1 <= a_i <= P; 1 <= b_i <= P). Driveway might connect a_i to itself or perhaps might connect two cities more than once. The Crisis Center is located in city 1.

A total of N (1 <= N <= P) survivors (in different cities) sequentially contacts Crisis Center via moobile phone with an integer message report_j (2 <= report_j <= P) that indicates that city report_j is undamaged but that the calling survivor is unable to return to the Crisis Center from city report_j because he/she could not find a path that does not go through damaged city.

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

Input

Input consists of several testcases. The format of each case as follow:

  • 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

    For each testcase, output a line with one number, the minimum number of damaged cities.

    Sample Input

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

    Sample Output

    1

    Hint

    Only city 2 being damaged gives such a scenario.

    Source

    Funny Programming Contest -- OSUM

    Submit  Back  Status  Discuss