#C11976. Count Distinct Passing Pairs
Count Distinct Passing Pairs
Count Distinct Passing Pairs
You are given the total number of players P and a list of ball passing events between players. Each passing event is represented by a pair of integers (i, j)
which indicates that player i
passed the ball to player j
.
A pair of players is counted as a distinct passing pair if there is at least one pass in one direction between them. In other words, if either (i, j)
or (j, i)
(or both) appears in the list, the pair is counted only once.
Your task is to determine the total number of such distinct passing pairs.
Note: The input is taken from standard input and the output must be printed to standard output.
Input Format (also see input description):
- The first line contains an integer P, the total number of players.
- The second line contains an integer N, the number of passing events.
- Each of the next N lines contains two integers
i
andj
indicating a passing event from playeri
to playerj
.
Output Format: Print a single integer which is the number of distinct passing pairs.
inputFormat
The input is given via standard input in the following format:
P N i1 j1 i2 j2 ... iN jN
Where:
P
is the total number of players.N
is the number of pass events.- Each of the following
N
lines contains two integers representing a pass from one player to another.
outputFormat
Output a single integer to standard output representing the count of distinct passing pairs.
## sample3
3
1 2
2 1
1 3
2
</p>