先上题目:

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.

  太久没敲题目,码个水题都卡了半天= =,题意:在给定的棋盘上面着色(两种颜色),要求相邻的两个不准有同一种颜色,同时还有一些格用不了。因为这一题的解有多个,最简单的办法就是先按照黑白相间的方式把格子都涂好色,然后把需要空出来的地方都空出来就可以了。

上代码:

 #include <bits/stdc++.h>
#define MAX 102
using namespace std; char s[MAX][MAX];
char c[MAX][MAX];
int n,m; int main()
{
//ios::sync_with_stdio(false);
//freopen("data.txt","r",stdin);
while(cin>>n>>m){
memset(c,,sizeof(c));
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]=='-') c[i][j]='-';
else{
if((i+j)%==) c[i][j]='W';
else c[i][j]='B';
}
}
for(int i=;i<n;i++) cout<<c[i]<<endl;
}
return ;
}

445A

CodeForces - 445A - DZY Loves Chessboard的更多相关文章

  1. CodeForces - 445A - DZY Loves Chessboard解题报告

    对于这题本人刚开始的时候觉得应该用DFS来解决实现这个问题,但由于本人对于DFS并不是太熟,所以就放弃了这个想法: 但又想了想要按照这个要求实现问题则必须是黑白相间,然后把是字符是'B'或'W'改为' ...

  2. CF 445A DZY Loves Chessboard

    A. DZY Loves Chessboard time limit per test 1 second memory limit per test 256 megabytes input stand ...

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

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

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

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

  6. CodeForces445A DZY Loves Chessboard

    A. DZY Loves Chessboard time limit per test 1 second memory limit per test 256 megabytes input stand ...

  7. 周赛-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 ...

  8. DZY Loves Chessboard

    DescriptionDZY loves chessboard, and he enjoys playing with it. He has a chessboard of n rows and m ...

  9. Codeforces 444C DZY Loves Colors(线段树)

    题目大意:Codeforces 444C DZY Loves Colors 题目大意:两种操作,1是改动区间上l到r上面德值为x,2是询问l到r区间总的改动值. 解题思路:线段树模板题. #inclu ...

随机推荐

  1. 解析Qt元对象系统(四) 属性系统(确实比较方便)

    官方解释 我们在Qt源码中可以看到一个QObject的子类经常会用到一些Q_开头的宏,例如QMainWindow类开始部分代码是这样的: Q_PROPERTY(QSize iconSize READ ...

  2. hihocoder 1680 hiho字符串2 dp求方案数+递归

    我们定义第一代hiho字符串是"hiho". 第N代hiho字符串是由第N-1代hiho字符串变化得到,规则是: h -> hio i -> hi o -> ho ...

  3. go-swagger的简单使用

    一.下载go-swagger go-swagger 官方下载 根据不同个的操作系统选择对应的 二.添加环境变量 2.1 window swagger_windows_amd64.exe 将swagge ...

  4. 【HDU1698】 Just a Hook 【线段树入门】

    原题:原题链接 题意:(机器翻译的...) 让我们将钩子的连续金属棒从1到N编号.对于每次操作,Pudge可以将连续的金属棒(从X到Y编号)改为铜棒,银棒或金棒. 钩的总值计算为N个金属棒的值的总和. ...

  5. [编码]ASCII、GBK、Unicode(万国码) 和 UTF-8

    American ASCII编码 (American Standard Code for Information Interchange,美国信息互换标准代码)  China    gbk编码     ...

  6. javascript跨域的几种方法

    以下的例子包含的文件均为为 http://www.a.com/a.html .http://www.a.com/c.html 与 http://www.b.com/b.html,要做的都是从a.htm ...

  7. 【Oracle】数据迁移工具(2):Data Dump

    Data Dump 使用命令行IMPDP/EXPDP实现导入导出表.schema.表空间及数据库.IMPDP/EXPDP命令行中可以加入以下选项,来实现更细粒度的导入导出. IMPDP/EXPDP和I ...

  8. C#:winform项目在win7,xp32位和64位都能运行

    vs中项目配置管理器活动解决方案平台选择X86平台.

  9. Content-Encoding值

    Content-Encoding值 gzip 表明实体采用GNU zip编码 compress 表明实体采用Unix的文件压缩程序 deflate 表明实体是用zlib的格式压缩的 identity ...

  10. python核心编程中的对象值比较VS对象身份比较(转载)

    转载地址: https://blog.csdn.net/Mluka/article/details/51076786 在python核心编程第四章中,P69在优化下面这段代码时提出了:对象值比较VS对 ...