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. bash正则表达式

    星号*: 匹配它前面的字符串或正则表达式任意次(包括0次). 比如:* 可能匹配的字符串有:... ...... 句号.: 匹配除换行符之外的任意一个字符. 比如:"112.",将 ...

  2. PHP获取不了React Native Fecth参数的解决办法代码是怎样?

    fetch('https://mywebsite.com/endpoint/', { method: 'POST',headers: {'Accept': 'application/json','Co ...

  3. C# 插件

    1.EsFrameWork框架 http://www.oraycn.com/ESFramework_download.aspx

  4. C Looooops(扩展欧几里得)

    C Looooops Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 20128 Accepted: 5405 Descripti ...

  5. DataRow数组转换DataTable

    public DataTable ToDataTable(DataRow[] rows) { if (rows == null || rows.Length == 0) return null; Da ...

  6. 分页sql存储过程算法

    /****** Object: StoredProcedure [dbo].[PRO_Pub_FenYe] Script Date: 08/04/2014 11:14:22 ******/ SET A ...

  7. TCP/IP通信实现

    网络层的IP协议提供不可靠通信服务.TCP协议则解决了分组的重传和排序问题. TCP通信特征 : 1)全双工,同时发送和接收数据 2)只支持两个端口之间的通信 3)基于字节流.对端无法知道报文的边界. ...

  8. 性能tips

    Latch 闩 锁的平级 采样时间不能太长,太频繁 一般情况下,性能图应该是一种趋势图,看的是趋势,不看某些单个点 在压测收集数据时,可能多种工具收集到的性能数据有少许差异,原因: 网络延迟,导致收集 ...

  9. ThinkPHP统一设置utf-8编码

    1.项目编码 在编辑器中设置编码utf-8 2.在浏览器中设置编码 //Thinkphp方法中添加header设置utf-8只有index方法解决了乱码 class UserAction extend ...

  10. 3094 寻找sb4

    3094 寻找sb4  时间限制: 1 s  空间限制: 32000 KB  题目等级 : 黄金 Gold 题解  查看运行结果     题目描述 Description sb有一天和sml吵架了,她 ...