COMP6651 Programming Assignment 3 Solved

30.00 \$

Category:
Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: . ` zip` solution files instantly, after Payment

Description

5/5 - (1 vote)

The World Chess Federation (F.I.D.E) are planning the World Chess Championship. tournament. One of the constraints they need to respect is to pair chess players from different countries. There are N professional chess players numbered from 0 to N âˆ’1 . FIDE does not have information about the citizenship of each chess player but they do know have some information about which players belong to the same country. Your task is to compute the number of ways possible to play a match between 2 players from different countries. You are provided with enough number of pairs so you succeed in your mission even though you donâ€™t know their citizenship right away. For example, if the players 1 , 2 and 3 are from the same country then the 2 pairs (1,2) and (2,3) give sufficient information and the third pair (1,3) is not needed.

1Â Â Â Â Â Â Â  Input and Output

The first line contains two integers, N and I separated by a single space. I lines follow. Each line contains 2 integers A and B separated by a single space such that

0 â‰¤ A,B â‰¤ N âˆ’ 1

1 â‰¤ N â‰¤ 105

1 â‰¤ I â‰¤ 104

A and B are chess players from the same country. The input should be taken from a separate input file. The output should be a single line displaying the number of permissible ways to choose a pair of chess players. There is no need to write it in a separate output file. You can display it on the console.

2Â Â Â Â Â Â  Sample Input

5 2

0 1

• 3

1

• Sample Output

8

4Â Â Â Â Â Â  Explanation

We have the following pairs (0,2),(0,3),(1,2),(1,3),(0,4),(1,4),(2,4),(3,4) where players are from different countries in each pair.

2

• player-match.zip