A. DZY Loves Chessboard
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

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.

Input

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

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.

Sample test(s)
input
1 1
.
output
B
input
2 2
..
..
output
BW
WB
input
3 3
.-.
---
--.
output
B-B
---
--B
Note

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.

MD,今天写这道题目的时候,想的太简单了,被一类数据搞得体无完肤。。。

Input
50 50
.........................--..................-....
............................................-.....
..-.....................................-.........
...........................-......................
........-.....................-...................
..................................................
.......-......-...................................
...-..................-.......................-...
.....-......-...............................-.....
...-................-...-..............
Output
BWBWBWBWBWBWBWBWBWBWBWBWB--BWBWBWBWBWBWBWBWBW-BWBW
WBWBWBWBWBWBWBWBWBWBWBWBWBWWBWBWBWBWBWBWBWBW-BWBWB
BW-WBWBWBWBWBWBWBWBWBWBWBWBBWBWBWBWBWBWB-BWBWWBWBW
WBWBWBWBWBWBWBWBWBWBWBWBWBW-BWBWBWBWBWBWBWBWBBWBWB
BWBWBWBW-WBWBWBWBWBWBWBWBWBWWB-BWBWBWBWBWBWBWWBWBW
WBWBWBWBWBWBWBWBWBWBWBWBWBWBBWBWBWBWBWBWBWBWBBWBWB
BWBWBWB-BWBWBW-WBWBWBWBWBWBWWBWBWBWBWBWBWBWBWWBWBW
WBW-WBWBWBWBWBWBWBWBWB-BWBWBBWBWBWBWBWBWBWBWBB-BWB
BWBWB-BWBWBW-WBWBWBWBWBWBWBWWBWBWBWBWBWBWBWB-WBWBW
WBW-WBWBWBWBWBWBWBWB-BWB-BWBBWBWBWBWBWBWBWB...
Answer
BWBWBWBWBWBWBWBWBWBWBWBWB--WBWBWBWBWBWBWBWBWB-BWBW
WBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWB-BWBWB
BW-WBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBW-WBWBWBWBW
WBWBWBWBWBWBWBWBWBWBWBWBWBW-WBWBWBWBWBWBWBWBWBWBWB
BWBWBWBW-WBWBWBWBWBWBWBWBWBWBW-WBWBWBWBWBWBWBWBWBW
WBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWB
BWBWBWB-BWBWBW-WBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBW
WBW-WBWBWBWBWBWBWBWBWB-BWBWBWBWBWBWBWBWBWBWBWB-BWB
BWBWB-BWBWBW-WBWBWBWBWBWBWBWBWBWBWBWBWBWBWBW-WBWBW
WBW-WBWBWBWBWBWBWBWB-BWB-BWBWBWBWBWBWBWBWBW... 一开始想的就是把每个格子按顺序填写好就没问题吧,这就是问题,当然不对了,在有拐角的地方,按顺序,就是错误!!
好吧,Json的方法,就是在已经打好的答案里填写字母,就OK,(这种方法很变态啊,积累吧)
 #include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
const int max_size = ; int main()
{
int row, col;
int graph[max_size][max_size];
int vis[max_size][max_size]; for(int i = ; i < max_size; i++)
{
for(int j = ; j < max_size; j++)
{
if((i+j) % == )
graph[i][j] = ;
else
graph[i][j] = ;
}
}
scanf("%d %d%*c", &row, &col); for(int i = ; i < row; i++)
{
for(int j = ; j < col; j++)
{
char a = getchar();
if(a == '-')
graph[i][j] = -;
}
getchar();
} for(int i = ; i < row; i++)
{
for(int j = ; j < col; j++)
{
if(graph[i][j] == )
printf("B");
else if(graph[i][j] == )
printf("W");
else
printf("-");
}
puts("");
}
return ;
}

代码

CodeForces445A DZY Loves Chessboard的更多相关文章

  1. (CF)Codeforces445A DZY Loves Chessboard(纯实现题)

    转载请注明出处:http://blog.csdn.net/u012860063? viewmode=contents 题目链接:http://codeforces.com/problemset/pro ...

  2. 周赛-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 ...

  3. DZY Loves Chessboard

    DescriptionDZY loves chessboard, and he enjoys playing with it. He has a chessboard of n rows and m ...

  4. cf445A DZY Loves Chessboard

    A. DZY Loves Chessboard time limit per test 1 second memory limit per test 256 megabytes input stand ...

  5. 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 ...

  6. CF 445A DZY Loves Chessboard

    A. DZY Loves Chessboard time limit per test 1 second memory limit per test 256 megabytes input stand ...

  7. Codeforces Round #254 (Div. 2) A. DZY Loves Chessboard —— dfs

    题目链接: http://codeforces.com/problemset/problem/445/A 题解: 这道题是在现场赛的最后一分钟通过的,相当惊险,而且做的过程也很曲折. 先是用递推,结果 ...

  8. CodeForces - 445A - DZY Loves Chessboard

    先上题目: A. DZY Loves Chessboard time limit per test 1 second memory limit per test 256 megabytes input ...

  9. A. DZY Loves Chessboard

    DZY loves chessboard, and he enjoys playing with it. He has a chessboard of n rows and m columns. So ...

随机推荐

  1. python学习笔记-(十六)python操作mysql

    一. mysql安装 1. windows下安装mysql 1.1. 下载源: http://dev.mysql.com/downloads/installer/,请认准对应版本 Windows (x ...

  2. WinForm------TextEdit只能输入数字

    代码: this.textEdit1.Properties.Mask.EditMask = @"\d+"; this.textEdit1.Properties.Mask.MaskT ...

  3. yuv420p转为emgucv的图像格式Emgu.CV.Image<Bgr, Byte>

    GCHandle handle = GCHandle.Alloc(yuvs, GCHandleType.Pinned); Emgu.CV.Image<Bgr, Byte> image = ...

  4. FreeCodeCamp练习笔记

    CSS样式表: 嵌套:body是最外层包围其他所有HTML元素(标签),其中的元素样式都可覆盖body的样式. 覆盖:同一元素有多个样式,位置靠后的样式覆盖位置靠前的样式. id:id与位置无关,可任 ...

  5. 解决Xftp经常断开连接的问题,Xftp中文乱码

    #文件 --> 选项 --> 勾选“发送保持活动状态消息” 间隔 60秒 #工具 -> 选项 延伸阅读: Xshell个性化设置,解决Xshell遇到中文显示乱码的问题

  6. JS学习:第一周——NO.1预解释

    1.何为预解释? 在当前作用域下,在JS代码执行之前,浏览器会对带var和带function的进行提前声明或定义: ①带var的:只声明不定义:告诉浏览器,有这么一个变量,但是并没有赋值 ②带func ...

  7. coding.net就这么横空出世

    各位新生们好: 看罢以上的开场白博客,我们也算初步完成了一个小程序——hello world.再进一步想下去,若我们程序写大了,要不停修改了(1000行代码不长,只争朝夕:-D),该如何保存呢?保存到 ...

  8. WindowsForm公共控件--2016年12月5日

    Button text:修改按钮显示的文字 CheckBox Checked:是否选中 CheckedListBox checkedListBox.Items.Add(显示的值,初始选中状态); ch ...

  9. 单词words

    论一类脑筋急转弯题和奇技淫巧题的解题技巧 [题意] 给定n个长为m且只包含xyz的字符串,定义两个字符串的相似程度为它们对应位置相同字符个数(比如xyz和yyz的相似程度为2,后两位相同),分别求出相 ...

  10. 核型SVM

    (本文内容和图片来自林轩田老师<机器学习技法>) 1. 核技巧引入 如果要用SVM来做非线性的分类,我们采用的方法是将原来的特征空间映射到另一个更高维的空间,在这个更高维的空间做线性的SV ...