cf445A DZY Loves Chessboard
1 second
256 megabytes
standard input
standard output
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.
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.
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.
1 1
.
B
2 2
..
..
BW
WB
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.
水……并且开黑用python过的
n, m = map(int, input().split())
for i in range(0, n):
s = input()
ans = ""
for j in range(0, m):
if s[j] == '.':
if (i + j) & 1 == 1:
ans = ans + "B"
else:
ans = ans + "W"
else:
ans = ans + s[j]
print(ans)
cf445A DZY Loves Chessboard的更多相关文章
- CodeForces445A DZY Loves Chessboard
A. DZY Loves Chessboard time limit per test 1 second memory limit per test 256 megabytes input stand ...
- 周赛-DZY Loves Chessboard 分类: 比赛 搜索 2015-08-08 15:48 4人阅读 评论(0) 收藏
DZY Loves Chessboard time limit per test 1 second memory limit per test 256 megabytes input standard ...
- DZY Loves Chessboard
DescriptionDZY loves chessboard, and he enjoys playing with it. He has a chessboard of n rows and m ...
- Codeforces Round #254 (Div. 2):A. DZY Loves Chessboard
A. DZY Loves Chessboard time limit per test 1 second memory limit per test 256 megabytes input stand ...
- CF 445A DZY Loves Chessboard
A. DZY Loves Chessboard time limit per test 1 second memory limit per test 256 megabytes input stand ...
- Codeforces Round #254 (Div. 2) A. DZY Loves Chessboard —— dfs
题目链接: http://codeforces.com/problemset/problem/445/A 题解: 这道题是在现场赛的最后一分钟通过的,相当惊险,而且做的过程也很曲折. 先是用递推,结果 ...
- (CF)Codeforces445A DZY Loves Chessboard(纯实现题)
转载请注明出处:http://blog.csdn.net/u012860063? viewmode=contents 题目链接:http://codeforces.com/problemset/pro ...
- CodeForces - 445A - DZY Loves Chessboard
先上题目: A. DZY Loves Chessboard time limit per test 1 second memory limit per test 256 megabytes input ...
- A. DZY Loves Chessboard
DZY loves chessboard, and he enjoys playing with it. He has a chessboard of n rows and m columns. So ...
随机推荐
- php防sql注入、xss
php自带的几个防止sql注入的函数http://www.php100.com/html/webkaifa/PHP/PHPyingyong/2013/0318/12234.html addslashe ...
- 使用FastClick的同时造成元素上的trigger('click')无法触发的解决办法
现象还原: 1. 初始化进入多规格卖场商详页的时候,chrome模拟器切换到安卓环境下,点击加入购物车,规格弹出页没有展示.而在PC和IOS模拟器下,可以弹出规格页 2. 点击加入购物车时,使用 $( ...
- Javascript:splice()方法实现对数组元素的插入、删除、替换及去重
定义和用法 splice() 方法向/从数组中添加/删除项目,然后返回被删除的项目. 注释:该方法会改变原始数组. 语法: Array.prototype.splice(index,count[,el ...
- JAVA的RSA加密算法工具类
须要用到一个jar http://www.bouncycastle.org/latest_releases.html 须要注意的问题 JS用同一秘钥生成的密文用java解密出来是逆序的,即js加密12 ...
- error C2143: 语法错误 : 缺少“;”(在“using”的前面)
class JJMenuScene : public cocos2d::CCLayer { public: // Here's a difference. Method 'init' in cocos ...
- Ajax原生XHR对象
前端学了有一段时间了,在项目中我通常使用的都是jQuery封装好的Ajax函数($.ajax.$.get.$.post),使用非常的简单方便,但为了更清楚的了解Ajax,需要学习原生xhr对象. ...
- VirtualBox虚拟机网络设置
VirtualBox虚拟机网络设置 测试环境:物理机win10企业版本,VirtaulBox版本5.0.14,虚拟机安装Windows XP及linux系统 想实现虚拟机上网的最简单方式,修改虚拟机网 ...
- LDAP 后缀操作
创建目录服务器实例之后,必须为服务器的目录信息树(Directory Information Tree,DIT)创建一个或多个后缀.DIT由服务器中的所有条目组成,这些条目使用各自的标识名(Disti ...
- 附加数据库报错:无法打开物理文件 XXX.mdf",操作系统错误 5:"5(拒绝访问。)"
今天在附加数据库的时候出现如图报错信息: 无法打开物理文件 XXX.mdf",操作系统错误 5:"5(拒绝访问.)"错信息如图:(是不是远程服务器数据库附加出现只读那个情 ...
- Java(TM) SE Development Kit 6 卸载不掉怎么办
错误描述:Java 安装时断电,再次安装java时,提示“您的电脑上已经安装了此软件.是否要重新安装”,点“是”后出现“内部错误2753:RegUtils”,点“确定”又出现上述提示. 解决办法 :使 ...