CF1569B.Chess Tournament
入门
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
A chess tournament will be held soon, where n chess 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.
一场国际象棋锦标赛即将举行,共有 n 名棋手参赛。每名选手都将与其他所有选手各进行一场比赛。每场比赛的结果要么是一方获胜、另一方失利,要么是双方战成平局。
每位选手对本次锦标赛都有自己的期望,期望类型只有以下两种之一:
- 该选手希望不输掉任何一场比赛(即:以零场失利的成绩结束锦标赛);
- 该选手希望至少赢下一场比赛。
你需要判断:是否存在一种所有比赛结果的安排方式,使得所有选手均满足各自的期望?若存在多种可行方案,输出任意一种即可;若不存在,则报告“不可能”。
输入格式
The first line contains a single integer t (1≤t≤200) — the number of test cases.
The first line of each test case contains one integer n (2≤n≤50) — the number of chess players.
The second line contains the string s (∣s∣=n; si∈1,2). If si=1, then the i-th player has expectations of the first type, otherwise of the second type.
第一行包含一个整数 t(1≤t≤200)—— 测试用例的数量。
每个测试用例的第一行包含一个整数 n(2≤n≤50)—— 国际象棋选手的数量。
每个测试用例的第二行包含一个字符串 s(∣s∣=n;si∈{1,2})。若 si=1,则第 i 位选手具有第一类期望;否则具有第二类期望。
输出格式
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 n×n in the next n lines.
The matrix element in the i-th row and j-th column should be equal to:
- +, if the i-th player won in a game against the j-th player;
- -, if the i-th player lost in a game against the j-th player;
- =, if the i-th and j-th players' game resulted in a draw;
- X, if i=j.
对于每个测试用例,请按以下格式输出答案:
第一行,如果无法满足所有玩家的期望,则输出 NO。
否则,输出 YES,并在接下来的 n 行中输出一个 n×n 的矩阵。
该矩阵第 i 行第 j 列的元素应为:
+,表示第 i 位玩家在与第 j 位玩家的对局中获胜;-,表示第 i 位玩家在与第 j 位玩家的对局中失利;=,表示第 i 位玩家与第 j 位玩家的对局结果为平局;X,当 i=j 时。
输入输出样例
输入#1
3 3 111 2 21 4 2122
输出#1
YES X== =X= ==X NO YES X--+ +X++ +-X- --+X
输入解题思路,AI测评打分。不知道怎么写?