Fingers
In the classic game of rock-paper-scissors, the rules are straightforward. Each of the two players selects one of three hand gestures: rock, scissors, or paper. Both players then reveal their choices simultaneously, and the winner is determined as follows: if both players choose the same gesture (e.g., rock vs. rock), the result is a draw; otherwise, rock defeats scissors, scissors defeat paper, and paper defeats rock. In some variations, additional items are introduced, which can make it unclear whether the game remains fair. A game is considered fair if each choice results in a draw against itself, wins against exactly half of the other choices, and loses to the remaining half. Given the description of such a game, your task is to determine the minimum number of choice pairs for which the outcome needs to be altered to ensure the game is fair.
Input
You are given an odd number N (1 ≤ N ≤ 100), representing the number of items. Following this, you receive an N×N matrix that describes the outcomes for different pairs of items. A 1 indicates a win, 0 indicates a draw, and -1 indicates a loss. The main diagonal of the matrix always contains 0. If a cell (i, j) contains 1, then the cell (j, i) must contain -1.
Output
Output the minimum number of item pairs for which the direction of victory needs to be changed to make the game fair.