#K34012. Maximum Permissible Games in a Chess Tournament

    ID: 25215 Type: Default 1000ms 256MiB

Maximum Permissible Games in a Chess Tournament

Maximum Permissible Games in a Chess Tournament

You are given a round-robin chess tournament where every pair of players is scheduled to play a game. However, some players refuse to compete against each other. For each test case, you need to compute the maximum number of games that can actually be arranged by subtracting the number of forbidden matchups from the total games in a complete tournament. The total number of games in a tournament with ( n ) players is given by ( \frac{n(n-1)}{2} ).

The input consists of multiple test cases. For each test case, the first line contains two integers, ( n ) and ( m ), where ( n ) is the number of players and ( m ) is the number of pairs that refuse to play. This is followed by ( m ) lines, each containing two integers representing a forbidden matchup.

inputFormat

The input begins with a single integer ( T ), the number of test cases. Each test case starts with a line containing two integers ( n ) (number of players) and ( m ) (number of forbidden games). It is followed by ( m ) lines, each containing two integers ( u ) and ( v ), indicating that the game between player ( u ) and player ( v ) will not be played.

outputFormat

For each test case, output a single integer on a new line representing the maximum number of permissible games that can be arranged.## sample

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

2 10

</p>