#K2831. Maximum Protected Cables

    ID: 24824 Type: Default 1000ms 256MiB

Maximum Protected Cables

Maximum Protected Cables

You are given a network of n computers and m directed cables connecting these computers. Additionally, k antivirus programs are installed on some of the computers. A cable, represented as a pair \( (a, b) \), is considered protected if at least one of its endpoints (either \( a \) or \( b \)) has an antivirus installed.

Your task is to determine how many cables are protected by the antivirus programs.

Note: The answer is determined by counting each cable where either the start or the end computer is protected.

Input Format:

  • The first line contains three integers: \( n \) (number of computers), \( k \) (number of antivirus programs), and \( m \) (number of cables).
  • The second line contains \( k \) space-separated integers representing the computers with antivirus installed.
  • The next \( m \) lines each contain two integers \( a \) and \( b \) which represent a directed cable from computer \( a \) to computer \( b \).

Output Format:

  • Output a single integer representing the number of protected cables.

inputFormat

The input starts with a single line containing three integers \( n \), \( k \), and \( m \).

The second line contains \( k \) integers indicating the positions (computer numbers) that have antivirus installed.

This is followed by \( m \) lines, each comprising two integers \( a \) and \( b \), indicating a directed cable from computer \( a \) to computer \( b \).

outputFormat

Print a single integer that denotes the number of cables which are protected, i.e., the cables for which at least one end has an antivirus program installed.

## sample
6 3 5
2 4 6
1 2
2 3
3 4
4 5
5 6
5

</p>