P23081 [AtCoder] [ABC010D] Preventing Infidelity
提高-
题目描述

Problem Description

Nagisa, the secretary of Takahashi, loves him very much. Today, she must monitor him to ensure that no bad influences attach to him.

Takahashi uses his own SNS to get friendly with girls. He traces friends on the SNS and sends messages to the girls he finds. Nagisa decided to perform some sabotage on the SNS to prevent girls from seeing Takahashi's messages.

The sabotage activities she can perform are the following two:

  • Dissolve the friendship between two specific people.
  • Change the password of a specific person to make them unable to log in. Takahashi's password cannot be changed. (Update at 21:11)

When a friendship is dissolved, Takahashi can no longer trace between those two people. However, this is not the case if he can trace through other friends.

Changing the password makes it impossible for that person to see the messages. Since the friendship remains unchanged, it is still possible to trace to another friend through the person whose password has been changed.

Nagisa wants to minimize the number of sabotage actions to ensure that the marked girls cannot view Takahashi's messages. Please calculate the minimum number of sabotage actions Nagisa needs to perform.

Input Format

The input is given from the standard input in the following format:

$ N $ $ G $ $ E $ $ p_1 $ $ p_2 $ ... $ p_G $ $ a_1 $ $ b_1 $ $ a_2 $ $ b_2 $ : $ a_E $ $ b_E $

  • The first line contains the number of registered users on the SNS, an integer $N\ (1\ ≦\ N\ ≦\ 100)$, the number of girls marked by Nagisa, $G\ (0\ ≦\ G\ ≦\ N\ -\ 1)$, and the number of friendships on the SNS, an integer $E\ (0\ ≦\ E\ ≦\ N\ ×\ (N-1)\ /\ 2)$, separated by spaces.
  • The second line contains $ G $ space-separated integers representing the ID of the $ i $-th marked girl, $p_i\ (1\ ≦\ p_i\ ≦\ N\ -\ 1)$.
  • The next $ E $ lines contain information about friendships. The $ i $-th line contains two space-separated integers $a_i\ (0\ ≦\ a_i\ ≦\ N\ -\ 1)$ and $b_i\ (0\ ≦\ b_i\ ≦\ N\ -\ 1)$, representing the ID numbers of the two people in the $ i $-th friendship.
  • It is guaranteed that when $i\ ≠\ j$, $a_i\ =\ a_j$ and $b_i\ =\ b_j$, or $a_i\ =\ b_j$ and $b_i\ =\ a_j$ will not occur.
  • In all inputs, it is guaranteed that Takahashi's ID is $ 0 $.

Output Format

Output the minimum number of sabotage actions Nagisa needs to perform in one line. End the output with a newline.

Sample Input and Output

Sample Input #1

4 2 3
2 3
0 1
1 2
1 3

Sample Output #1

1

Sample Input #2

4 1 4
3
0 1
0 2
1 3
2 3

Sample Output #2

1

Sample Input #3

10 3 11
7 8 9
0 1
0 2
0 3
0 4
1 5
2 5
5 6
6 7
6 8
3 9
4 9

Sample Output #3

2

Sample Input #4

6 2 6
4 5
0 1
0 2
1 3
2 3
3 4
3 5

Sample Output #4

2

Sample Input #5

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

Sample Output #5

0

Notes/Hints

Partial Points

If you correctly solve the test cases where $0\ ≦\ E\ ≦\ 12$, you will be awarded 99 points as partial credit.

Sample Explanation 1

As shown in the figure, dissolving one friendship is enough to disconnect two girls from Takahashi.

Sample Explanation 2

Since there is only one marked girl, disabling her login is sufficient to achieve the goal.

Sample Explanation 3

By performing sabotage as shown in the figure, it is possible to act against all the girls.

Sample Explanation 4

Note that disabling the login of the person with ID $ 3 $ does not affect Takahashi's ability to find friends.

Sample Explanation 5

Since Takahashi has no friends, no sabotage is necessary.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
4 2 3 2 3 0 1 1 2 1 3
样例输出
1