Description
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 Input
Input
1 1
.
Output
B
Input
2 2
..
..
Output
BW
WB
Input
3 3
.-.
---
--.
Output
B-B
---
--B
Hint
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.

 //这是一道bfs题,但是也可以当成一道模拟题。。。我目前算法比较渣,但是想到了这种方法
//先把格子填满,输入'.'时只要把对应填好的B 或 W替换掉就可以了
#include <stdio.h>
#include <string.h>
char map[][];
char in[][]; int main()
{
int i,j,m,n,t;
for(i=;i<;i++)
{
for(j=;j<;j++)
{
if((i+j)%)map[i][j]='B';
else map[i][j]='W';
}
}
while(~scanf("%d %d",&n,&m))
{
getchar();
memset(in,,sizeof (in));
for(i=;i<n;i++)
{
gets(in[i]);
}
for(i=;i<n;i++)
{
for(j=;j<m;j++)
{
if(in[i][j]=='.')in[i][j]=map[i][j];
}
}
for(i=;i<n;i++)
puts(in[i]);
}
return ;
}

DZY Loves Chessboard的更多相关文章

  1. CodeForces445A DZY Loves Chessboard

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

  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. cf445A DZY Loves Chessboard

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

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

  5. CF 445A DZY Loves Chessboard

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

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

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

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

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

  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. 【Pro ASP.NET MVC 3 Framework】.学习笔记.6.SportsStore:导航

    在之前的章节,偶们设置了核心的基础设施,现在我们将使用基础设计添加关键特性,你将会看到投资是如何回报的.我们能够很简单很容易地添加重要的面向客户的特性.沿途,你也会看到一些MVC框架提供的附加的特性. ...

  2. WebService工作原理

    1.WebService工作原理-SOAP 当客户端调用一个WebService的方法时,首先将方法名称和需要传递的参数包装成XML,也就是SOAP包,通过HTTP协议传递到服务器端,然后服务器端解析 ...

  3. MVP MVC MVVM 傻傻分不清

    最近MVC (Model-View-Controller) 和MVVM (Model-View-ViewModel) 在微软圈成为显学,ASP.NET MVC 和WPF 的Prism (MVVM Fr ...

  4. HDU 5876:Sparse Graph(BFS)

    http://acm.hdu.edu.cn/showproblem.php?pid=5876 Sparse Graph Problem Description   In graph theory, t ...

  5. Function对象属性和方法

    /* var pattern = /^[\w]+\.(zip|rar|gz)$/; //|选择符必须用分组符号包含起来 var str = '123.7z'; alert(pattern.test(s ...

  6. webconfig简单加密解密

    <?xml version="1.0"?><configuration> <configSections> <section name=& ...

  7. 跟我一起Django - 01 安装和初始化

    跟我一起Django - 01 安装和初始化 python环境 C:\Python27\Lib\site-packages>python --versionPython 2.7.5 安装setu ...

  8. Present

    Present time limit per test 2 seconds memory limit per test 256 megabytes input standard input outpu ...

  9. 谈EXPORT_SYMBOL使用

    EXPORT_SYMBOL只出现在2.6内核中,在2.4内核默认的非static 函数和变量都会自动导入到kernel 空间的, 都不用EXPORT_SYMBOL() 做标记的.2.6就必须用EXPO ...

  10. MBB类似jquery.bxslider插件轮播效果

    首先,如图一:当打开页面是,产品出现了淡入淡出切换轮播状态,当鼠标点击左边的小图时,就会切换出相对应的大图,当鼠标移开的时候,这个轮播就会停止自动轮播,只有人工手动才能进行切换:是一个不错的体验! 如 ...