QOJ.ac

QOJ

Süre Sınırı: 2 s Bellek Sınırı: 256 MB Toplam puan: 100

#22396. 지진 피해 2

İstatistikler

위스콘신의 지진이 Farmer John의 농장을 덮쳤다! 일부 목초지가 손상되어 통과할 수 없다. 놀랍게도 소 길은 하나도 손상되지 않았다.

농장은 $P$개 목초지 ($1 \le P \le 3,000$, 번호 $1..P$)와 이를 잇는 $C$개 무방향 소 길 ($1 \le C \le 20,000$, 번호 $1..C$)로 이루어진다. 길 $i$는 $a_{i}$와 $b_{i}$를 잇는다 ($1 \le a_{i} \le P; 1 \le b_{i} \le P$). 자기 자신을 잇거나 같은 두 목초지를 여러 번 이을 수 있다. 헛간은 목초지 1에 있다.

서로 다른 목초지의 $N$마리 소 ($1 \le N \le P$)가 차례로 휴대폰으로 정수 $report_{j}$ ($2 \le report_{j} \le P$)를 보고한다. 해당 목초지가 손상되지 않았지만 손상된 목초지를 지나지 않는 길을 찾지 못해 헛간으로 돌아갈 수 없다는 뜻이다.

모든 보고가 끝나면 손상된 목초지의 최소 수를 구하라.

입력

  • 1번째 줄: 공백으로 구분된 세 정수 $P$, $C$, $N$.

  • $2..C+1$번째 줄: $i+1$번째 줄은 두 정수 $a_{i}$와 $b_{i}$로 길 $i$를 설명한다.

  • $C+2..C+N+1$번째 줄: $C+1$ $+$ $j$번째 줄에 정수 $report_{j}$가 주어진다.

출력

  • 1번째 줄: 손상된 목초지의 최소 수 하나.

예제

입력 1

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

출력 1

1

참고

목초지 2만 손상되면 이러한 상황이 된다.

문제 출제자: 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.