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 ;
}

代码

最新文章

  1. Web应用程序的自动化测试库-FluentAutomation
  2. flex align-content中的描述的“多根轴线的对齐方式”中的“多根轴线”到底是什么
  3. SQL Server选项综述
  4. .net 发展史
  5. 让所有的浏览器都支持html5
  6. ABAP之声母韵母
  7. 寻找研究基于NS2研究覆盖网络的小伙伴:)
  8. 堆heap和栈Stack(百科)
  9. 新浪微博顶部新评论提示层效果——position:fixed
  10. Apache MINA 框架之Handler介绍
  11. Android 测试工具集01
  12. Asp.Net MVC4配置Ext.Net
  13. string和byte[]的转换 (C#)
  14. [HAOI 2007]上升序列
  15. [USACO08JAN]跑步Running
  16. [再寄小读者之数学篇](2014-06-23 Gronwall-type inequality)
  17. magic
  18. 很不幸,装win10和Ubuntu双系统还是入坑了
  19. Visual Studio Code 常用快捷键
  20. [sh]basename&amp;dirname截取路径和文件名&amp;case参数选项

热门文章

  1. 自定义checkbox风格
  2. shell的一些应用场景
  3. 10 件有关 JavaScript 让人费解的事情
  4. Error: Collection was modified; enumeration operation may not execute.
  5. go智能提示(重要)
  6. 新一代记事本“Notepad++”个性化设置备份
  7. JS跨域(ajax跨域、iframe跨域)解决方法及原理详解(jsonp)
  8. jvm七种垃圾收集器
  9. vue 列表渲染
  10. espcms会员二次开发文件说明——会员,时间格式