Grand Game Tournament
Time limit2sMemory limit256 MB
Given partial results of a round-robin with draws, find every player who can still finish with the maximum score.
- Level
Medium6 of 10
- Topics
- Graph, Greedy, Implementation
- Solved
- No attempts yet
Problem
The "Grand Game Tournament" is the most famous game competition in the world.
Every player plays exactly one 1-vs-1 game against every other player. In each game the winner earns 1 point and the loser earns 0 points; if the game is a draw, both players earn 0.5 points. After all games are finished, the player with the highest score is the champion. If several players are tied for the highest score, they play tie-break games among themselves until a single champion remains. Therefore any player whose final score equals the maximum score has a chance to win the tournament.
The tournament is still in progress and only some of the games have been played. For each player, if the not-yet-played games can be completed in some way so that this player ends up with the maximum final score (ties for first included), then that player "can win" the tournament. Find every player who can win.
Input
The first line contains the number of test cases ().
Each test case is given as follows.
- The first line contains the number of players ().
- The next lines give the current partial results as an grid. The -th character of the -th line is the result of the game between player and player .
1: player won0: player lostd: draw.: the game has not been played yetx: (a player does not play against themselves)
The partial results are consistent: if row column is 1, then row column is 0, and vice versa; a cell that is d or . equals the cell in the mirrored position.
Output
For each test case, print on one line the numbers (1-indexed) of all players who can win, in ascending order, separated by spaces.