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 ...
随机推荐
- Scala-的元组和映射
package com.mengyao.scala.function /** * Scala 映射 * Scala中的Key,Value集合被称为映射,映射中的每一个key,value称为对偶 * ...
- <Win32_9>有意思的程序——抓取屏幕
Win32学了一段时间了,跟着杨老师的脚步,准备学习MFC,因此最近几天在复习C++,于是发现有将近一周没写博文了…… 今天来写一个较为简单.但是比较有意思的东西 不知大家在理发店理发的时候注意到一个 ...
- storm 事务和DRPC结合
示例代码: package com.lky.topology; import backtype.storm.Config; import backtype.storm.LocalCluster; im ...
- js日期和毫秒相互转换
var date = new Date(); var n = date.valueOf() var date2 = new Date(n); console.info(date.valueOf()); ...
- HTML获取用户输入的几种玩法
input标签 input是一个自闭和标签,可以获得用户的输入 form标签 form标签是用来进行表单提交用的,它把用户的输入内容提交到服务器. 一个注册页面的例子 <!DOCTYPE htm ...
- (转)Linux bash shell脚本语法入门
http://www.linuxsky.org/doc/newbie/201004/389.html 1.基础 #!/bin/bash //bash脚本第一句都是这个,他会让系统指定以bash来解释这 ...
- 50个Android开发技巧(10 为TextView加入样式)
首先来看一个控件的例子: (原文地址:http://blog.csdn.net/vector_yi/article/details/24428085) 手机上类似这种场景你一定已经见过非常多次了,但有 ...
- android repo库的创建及代码管理
- Spring3 MVC 使用JSON进行前后台数据交互
http://wbj0110.iteye.com/blog/2007918 在 Spring3 中,响应.接受 JSON都十分方便.向前台返回 JSON 格式的数据: 1 2 3 4 5 6 7 8 ...
- Chrome Browser
set default search engine as follow for force encrypted searching: https://encrypted.google.com/sear ...