#K80837. Chess Tournament Analysis

    ID: 35619 Type: Default 1000ms 256MiB

Chess Tournament Analysis

Chess Tournament Analysis

In a round-robin chess tournament, n players each play against every other player exactly once. The outcome of each game is recorded in an n x n matrix \(M\), where:

  • \(M[i][j] = 1\) if player \(i\) wins against player \(j\),
  • \(M[i][j] = -1\) if player \(i\) loses to player \(j\), and
  • \(M[i][j] = 0\) if the game ends in a draw or if \(i = j\).

Alice is the first player (index 0) and her performance is of special interest. Your task is to calculate and print the following statistics:

  1. The total number of games played in the tournament, which is \(\frac{n \times (n-1)}{2}\).
  2. The number of wins for Alice.
  3. The number of losses for Alice.
  4. The number of draws for Alice (games that ended in a draw, excluding the self-match).

Print these four numbers in a single line separated by spaces.

inputFormat

The first line contains an integer \(n\) representing the number of players.

The next \(n\) lines each contain \(n\) space-separated integers representing the matrix \(M\). The \(j\)-th number in the \(i\)-th line denotes the result of the game between players \(i\) and \(j\).

outputFormat

Output a single line containing four space-separated integers: the total number of games in the tournament, the number of wins for Alice, the number of losses for Alice, and the number of draws for Alice.

## sample
3
0 1 -1
-1 0 1
1 -1 0
3 1 1 0

</p>