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.

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm> using namespace std; const int M = 1000 + 5;
char str[M][M];
int a, b; int main()
{
while(scanf("%d%d", &a, &b)!=EOF)
{
memset(str, 0, sizeof(str));
for(int i=1; i<=a; i++)
for(int j=1; j<=b; j++)
cin>>str[i][j];
for(int i=1; i<=a; i++)
for(int j=1; j<=b; j++)
{
if(str[i][j]=='.')
{
if((i+j)%2==0)
str[i][j]='B';
else
str[i][j]='W';
}
}
for(int i=1; i<=a; i++)
{
for(int j=1; j<=b; j++)
cout<<str[i][j];
cout<<endl;
}
} return 0;
}

版权声明:本文博客原创文章。博客,未经同意,不得转载。

Codeforces Round #254 (Div. 2):A. DZY Loves Chessboard的更多相关文章

  1. Codeforces Round #254 (Div. 2):B. DZY Loves Chemistry

    B. DZY Loves Chemistry time limit per test 1 second memory limit per test 256 megabytes input standa ...

  2. Codeforces Round #FF (Div. 2):C. DZY Loves Sequences

    C. DZY Loves Sequences time limit per test 1 second memory limit per test 256 megabytes input standa ...

  3. Codeforces Round #FF (Div. 2):Problem A - DZY Loves Hash

    A. DZY Loves Hash time limit per test 1 second memory limit per test 256 megabytes input standard in ...

  4. Codeforces Round 254 (Div. 2)

    layout: post title: Codeforces Round 254 (Div. 2) author: "luowentaoaa" catalog: true tags ...

  5. Codeforces Round #254 (Div. 1) C. DZY Loves Colors 线段树

    题目链接: http://codeforces.com/problemset/problem/444/C J. DZY Loves Colors time limit per test:2 secon ...

  6. Codeforces Round #254 (Div. 1) D. DZY Loves Strings hash 暴力

    D. DZY Loves Strings 题目连接: http://codeforces.com/contest/444/problem/D Description DZY loves strings ...

  7. Codeforces Round #254 (Div. 1) C. DZY Loves Colors 分块

    C. DZY Loves Colors 题目连接: http://codeforces.com/contest/444/problem/C Description DZY loves colors, ...

  8. Codeforces Round #254 (Div. 1) A. DZY Loves Physics 智力题

    A. DZY Loves Physics 题目连接: http://codeforces.com/contest/444/problem/A Description DZY loves Physics ...

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

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

随机推荐

  1. elasticsearch2.2

    elasticsearch2.2 集群搭建各种坑     目前生产环境的es版本是1.0版本,需要升级到最新的2.2版本,于是在测试环境进行部署集群测试,在测试过程中遇到的坑相当多,下面详细介绍下. ...

  2. 使用CMakeLists.txt 判断编译器是否支持C++11

    #将下面的内容添加到CMakeLists.txt当中include(CheckCXXCompilerFlag) CHECK_CXX_COMPILER_FLAG("-std=c++11&quo ...

  3. POJ2239 Selecting Courses【二部图最大匹配】

    主题链接: http://poj.org/problem?id=2239 题目大意: 学校总共同拥有N门课程,而且学校规定每天上12节可,一周上7天. 给你每门课每周上的次数,和哪一天哪一节 课上的. ...

  4. 【v2.x OGE课程 14】 控制使用

    在这里,精灵.动画精灵.button天才.经常使用的文本的使用 一个.相关精灵 1.加入精灵 //创建精灵 Sprite bar_up = new Sprite(400, 0, RegionRes.g ...

  5. 【程序员联盟】官网上线啦!coderunity.com

    内容简介 欢天喜地,[程序员联盟]官网上线咯(此处应该有鸡蛋丢过来...) [程序员联盟]官网 大家也许会问:“这几天小编都没出文章,跑哪里happy去啦?是不是偷懒去了?” 小编:“臣妾冤枉啊.” ...

  6. PowerDesigner创建物理模型

    原文:PowerDesigner创建物理模型 Using PowerDesigner Create PDM 1.打开PowerDesigner 按Ctrl+N 创建物理模型 2.创建后修改名称,并在工 ...

  7. YT新人之巅峰大决战04

    Problem Description Eddy's interest is very extensive, recently he is interested in prime number. Ed ...

  8. 深入理解JavaScript系列(33):设计模式之策略模式(转)

    介绍 策略模式定义了算法家族,分别封装起来,让他们之间可以互相替换,此模式让算法的变化不会影响到使用算法的客户. 正文 在理解策略模式之前,我们先来一个例子,一般情况下,如果我们要做数据合法性验证,很 ...

  9. some notions about os

    1. Multiprogramming system provide an environment in which the various resources (like CPU,memory,an ...

  10. SharePoint 2010 Form Authentication (SQL) based on existing database

    SharePoint 2010 表单认证,基于现有数据库的用户信息表 本文主要描写叙述本人配置过程中涉及到的步骤,仅作为參考,不要仅限于此步骤. 另外本文通俗易懂,适合大众口味儿. I. 开启并配置基 ...