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. 使用yum安装报错:[Errno 256] No more mirrors to try

    背景:我使用yum方式安装软件时,比如zabbix这种软件,我们在安装时一般都是直接到zabbix官网,按照官方的步骤进行安装,但是有一个问题,官方的服务器不在国内,时常会在安装时导致超时报错.此时解 ...

  2. ansible笔记(14):循环(一)

    在使用ansible的过程中,我们经常需要处理一些返回信息,而这些返回信息中,通常可能不是单独的一条返回信息,而是一个信息列表,如果我们想要循环的处理信息列表中的每一条信息,我们该怎么办呢?这样空口白 ...

  3. [HNOI2013] 消毒 - 二分图匹配

    容易发现 \(a,b,c\) 中至少有一个 \(\leq 17\) 不妨将其调剂为 \(a\),那么我们可以暴力枚举哪些 \(x\) 片片要被直接削掉,剩下的拍扁成二维情况 二维时,如果有一个格子是 ...

  4. HttpRequestException encountered解决方法

    每次pull代码的时候,总是要输入账号,密码,百度了一下HttpRequestException encountered错误 发现是Github 禁用了TLS v1.0 and v1.1,必须更新Wi ...

  5. 363. 矩形区域不超过 K 的最大数值和(利用前缀和转化为最大子序和问题)

    题目: 链接:https://leetcode-cn.com/problems/max-sum-of-rectangle-no-larger-than-k/ 给定一个非空二维矩阵 matrix 和一个 ...

  6. numpy Array[:,]的取值方法

  7. echart --toolbox

    1.自定义的toolbox 消息回调 toolbox: { show: true, itemSize: 32, borderColor: '#0cb1b6', borderWidth: 1, bord ...

  8. OrCAD 仿真与仿真模块库介绍

    PSpice A/D9.1个别时候可能会出现异常现象,例如:某一步后,突然电路图的电源极性被自动改变了!造成直流电压和直流电流不正常,输出无波形.所以应该趁正常的时候做好备份是明智的. PSpice ...

  9. 切换目录命令 - cd

    1) 命令名称:cd 2) 英文原意:change directory 3) 命令所在路径:shell 内置命令 4) 执行权限:所有用户 5) 功能描述:切换目录 6) 语法: cd[目录名] 例子 ...

  10. ubuntu19.04 安装mysql,没有初始密码,重设初始密码

    1.安装 在终端下输入 sudo apt-get install mysql-server mysql-client 进行安装,如果安装过程中弹出密码输入提示,则正常安装即可! 2.由于没有出现密码设 ...