CF445A.DZY Loves Chessboard
普及-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
DZY loves chessboard, and he enjoys playing with it.
He has a chessboard of n rows and m columns. Some cells of the chessboard are bad, others are good. For every good cell, DZY wants to put a chessman on it. Each chessman is either white or black. After putting all chessmen, DZY wants that no two chessmen with the same color are on two adjacent cells. Two cells are adjacent if and only if they share a common edge.
You task is to find any suitable placement of chessmen on the given chessboard.
DZY 热爱国际象棋棋盘,也喜欢与之玩耍。
他有一个 n 行 m 列的棋盘。棋盘上的一些格子是坏的,其余的是好的。对于每个好的格子,DZY 都想在其上放置一枚棋子。每枚棋子要么是白色,要么是黑色。在放置完所有棋子后,DZY 希望任意两个相邻格子上的棋子颜色均不相同。当且仅当两个格子有一条公共边时,它们才被认为是相邻的。
你的任务是在给定的棋盘上找出一种满足条件的棋子放置方案(任意一种即可)。
输入格式
The first line contains two space-separated integers n and m (1 ≤ n, m ≤ 100).
Each of the next n lines contains a string of m characters: the j-th character of the i-th string is either "." or "-". A "." means that the corresponding cell (in the i-th row and the j-th column) is good, while a "-" means it is bad.
第一行包含两个以空格分隔的整数 n 和 m(1 ≤ n, m ≤ 100)。
接下来的 n 行中,每行包含一个长度为 m 的字符串:第 i 行字符串中的第 j 个字符为 “.” 或 “-”。其中,“.” 表示对应单元格(第 i 行、第 j 列)是好的,而 “-” 表示该单元格是坏的。
输出格式
Output must contain n lines, each line must contain a string of m characters. The j-th character of the i-th string should be either "W", "B" or "-". Character "W" means the chessman on the cell is white, "B" means it is black, "-" means the cell is a bad cell.
If multiple answers exist, print any of them. It is guaranteed that at least one answer exists.
输出必须包含 n 行,每行必须包含一个长度为 m 的字符串。第 i 行的第 j 个字符应为 "W"、"B" 或 "-" 之一。字符 "W" 表示该格子上放置的是白棋子,"B" 表示该格子上放置的是黑棋子,"-" 表示该格子为坏格子。
若存在多个合法答案,输出任意一个即可。题目保证至少存在一个合法答案。
输入输出样例
输入#1
1 1 .
输出#1
B
输入#2
2 2 .. ..
输出#2
BW WB
输入#3
3 3 .-. --- --.
输出#3
B-B --- --B
说明/提示
In the first sample, DZY puts a single black chessman. Of course putting a white one is also OK.
In the second sample, all 4 cells are good. No two same chessmen share an edge in the sample output.
In the third sample, no good cells are adjacent. So you can just put 3 chessmen, no matter what their colors are.
在第一个样例中,DZY 放置了一枚黑色棋子。当然,放置一枚白色棋子也是可以的。
在第二个样例中,全部 4 个格子都是好格子。在样例输出中,没有两枚相同颜色的棋子共享一条边。
在第三个样例中,不存在相邻的好格子。因此,你可以恰好放置 3 枚棋子,且它们的颜色任意。
输入解题思路,AI测评打分。不知道怎么写?