Chess Tournament solution codeforces
A chess tournament will be held soon, wherechess players will take part. Every participant will play one game against every other participant. Each game ends in either a win for one player and a loss for another player, or a draw for both players.
Each of the players has their own expectations about the tournament, they can be one of two types:
- a player wants not to lose any game (i. e. finish the tournament with zero losses);
- a player wants to win at least one game.
You have to determine if there exists an outcome for all the matches such that all the players meet their expectations. If there are several possible outcomes, print any of them. If there are none, report that it’s impossible.
The first line contains a single integer( ) — the number of test cases.
The first line of each test case contains one integer( ) — the number of chess players.
The second line contains the string( ; ). If , then the -th player has expectations of the first type, otherwise of the second type.
For each test case, print the answer in the following format:
In the first line, print NO if it is impossible to meet the expectations of all players.
Otherwise, print YES, and the matrix of size in the next lines.
The matrix element in the-th row and -th column should be equal to:
- +, if the -th player won in a game against the -th player;
- –, if the -th player lost in a game against the -th player;
- =, if the -th and -th players’ game resulted in a draw;
- X, if .
3 3 111 2 21 4 2122
YES X== =X= ==X NO YES X--+ +X++ +-X- --+X
Also read : Chess Tournament solution codeforces