303819: CF736E. Chess Championship

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Chess Championship

题目描述

Ostap is preparing to play chess again and this time he is about to prepare. Thus, he was closely monitoring one recent chess tournament. There were $ m $ players participating and each pair of players played exactly one game. The victory gives $ 2 $ points, draw — $ 1 $ points, lose — $ 0 $ points. Ostap is lazy, so he never tries to remember the outcome of each game. Instead, he computes the total number of points earned by each of the players (the sum of his points in all games which he took part in), sort these value in non-ascending order and then remembers first $ n $ integers in this list. Now the Great Strategist Ostap wonders whether he remembers everything correct. He considers that he is correct if there exists at least one tournament results table such that it will produce the given integers. That means, if we count the sum of points for each player, sort them and take first $ n $ elements, the result will coincide with what Ostap remembers. Can you check if such table exists?

输入输出格式

输入格式


The first line of the input contains two integers $ m $ and $ n $ ( $ 1<=n<=m<=3000 $ ) — the number of participants of the tournament and the number of top results Ostap remembers. The second line contains $ n $ integers, provided in non-ascending order — the number of points earned by top participants as Ostap remembers them. It's guaranteed that this integers are non-negative and do not exceed $ 2·m $ .

输出格式


If there is no tournament such that Ostap can obtain the given set of integers using the procedure described in the statement, then print "no" in the only line of the output. Otherwise, the first line of the output should contain the word "yes". Next $ m $ lines should provide the description of any valid tournament. Each of these lines must contain $ m $ characters 'X', 'W', 'D' and 'L'. Character 'X' should always be located on the main diagonal (and only there), that is on the $ i $ -th position of the $ i $ -th string. Character 'W' on the $ j $ -th position of the $ i $ -th string means that the $ i $ -th player won the game against the $ j $ -th. In the same way character 'L' means loose and 'D' means draw. The table you print must be consistent and the points earned by best $ n $ participants should match the memory of Ostap. If there are many possible answers, print any of them.

输入输出样例

输入样例 #1

5 5
8 6 4 2 0

输出样例 #1

yes
XWWWW
LXWWW
LLXWW
LLLXW
LLLLX

输入样例 #2

5 1
9

输出样例 #2

no

Input

题意翻译

## 题目描述 一场国际象棋比赛,有 $M$ 个玩家参加,每对玩家恰好玩一场比赛。胜利加 $2$ 分,平局 $1$ 分,输不加分。 你不知道具体的情况,只知道排名前 $n$ 的人的分数,构造一种胜负情况,使得这个排名是正确的。 ## 输入格式 第一行两个整数 $m,n$ ,含义见题目描述。 第二行 $n$ 个整数,表示排名前 $n$ 的人的分数。 ## 输出格式 如果不存在这样的局面,输出 `no` 。 否则先一行输出 `yes` ,接着 $m$ 行,构造一个 $m$ 行 $m$ 列的胜负矩阵,包含 `X`,`W`,`L`,`D` 。分别表示: 若 $i=j$ , 则 $i$ 行 $j$ 列为 `X` 。 若 $i$ 赢了 $j$ , 则 $i$ 行 $j$ 列为 `W` 。 若 $i$ 输了 $j$ , 则 $i$ 行 $j$ 列为 `L` 。 若 $i$ 平了 $j$ , 则 $i$ 行 $j$ 列为 `D` 。 多解输出任意一解即可。

加入题单

算法标签: