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.

Examples
input

Copy
1 1
.
output

Copy
B
input

Copy
2 2
..
..
output

Copy
BW
WB
input

Copy
3 3
.-.
---
--.
output

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

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <numeric>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#define ll long long
using namespace std;
int dir[][] = { {,},{-,},{,},{,-} };
int n, m;
vector<string> s(n);
void dfs(int x, int y, bool t)
{
s[x][y] = (t ? 'B' : 'W');
for (int i = ; i < ; i++)
{
int nx = x + dir[i][];
int ny = y + dir[i][];
if (nx>= && ny>= && nx+<=n && ny+<=m && s[nx][ny]=='.')
dfs(nx, ny, t ^ );
}
}
int main()
{
cin >> n >> m;
s.resize(n);
for (int i = ; i < n; i++)
cin >> s[i];
for (int i = ; i < n; i++)
{
for (int j = ; j < m; j++)
{
if (s[i][j] == '.') dfs(i, j, );
}
}
for (int i = ; i < n; i++)
{
if (i == n - )
cout << s[i];
else
cout << s[i] << endl;
}
//system("pause");
return ;
}

A. 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. 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. (CF)Codeforces445A DZY Loves Chessboard(纯实现题)

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

  9. CodeForces - 445A - DZY Loves Chessboard

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

随机推荐

  1. BandwagonHost VPS CentOS7系统启用EPEL源

    BandwagonHost默认安装好了EPEL源,只是默认没有启用,所以很多软件都无法安装.我们需要手动启用一下,才能安装里面的软件. # vim /etc/yum.repos.d/epel.repo ...

  2. STM 32 内部功能回顾

    EXTI   外部中断 NVIC 嵌套的向量式中断控制器 AHB 是高级高性能内部总线,主要是用在CPU.DMA.DSP(数字信号处理) APB 是外围总线,I2C. 串口 APB 分为高速APB2( ...

  3. 怎么把apk文件部署在云服务器上

    你服务器直接使用nginx,将请求映射到固定目录,把你的apk放到该目录.其他都不用干了.

  4. spring项目中 通过自定义applicationContext工具类获取到applicationContext上下文对象

    spring项目在服务器启动的时候 spring容器中就已经被创建好了各种对象,在我们需要使用的时候可以进行调用. 工具类代码如下 import org.springframework.beans.B ...

  5. 字符串UTF-8和GBK之间的转换以及判定

    一.判定字符串是否是UTF-8的编码 bool is_str_utf8(const char* str) { unsigned ;//UFT8可用1-6个字节编码,ASCII用一个字节 unsigne ...

  6. dp--B - Hard problem

    B - Hard problem Vasiliy is fond of solving different tasks. Today he found one he wasn't able to so ...

  7. php基础系列之 数据的存储和读取

    ·文件处理 ·写入一个文件 1,打开这个文件.如果这个文件不存在,需要先创建它 2,将数据写入这个文件 3,关闭这个文件 ·从一个文件读出数据 1,打开这个文件.如果这个文件不能打开(例如,文件不存在 ...

  8. git创建远程分支并推送

    1.查看所有分支(-a=>'查看全部的分支') git branch -a 2.创建本地test分支 git branch test 2.2切换test分支 git checkout test ...

  9. exists和not exists关键字

    表A ID NAME 1    A1 2    A2 3  A3 表B ID AID NAME 1    1 B1 2    2 B2 3    2 B3 SELECT ID,NAME FROM A ...

  10. mybatis(六):设计模式 - 单例模式