先上题目:

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. Modern Qt Development: The Top 10 Tools You Should Be Using

    Published Friday October 12th, 2018Leave a comment Posted in Biz Circuit & Dev Loop, C++, QtCrea ...

  2. E20170830-mk

    translation  n. 翻译; 译本; 转化; 转变; calculate  vt. 计算; 估计; 打算,计划; 旨在; erase  vt. 抹去; 清除; 擦掉;

  3. sqlserver导入数据到mysql的详细图解

    SQL Server 迁移数据到MySQL 一.背景 由于项目开始时候使用的数据库是SQL Server,后来把存储的数据库调整为MySQL,所以需要把SQL Server的数据转移到MySQL:由于 ...

  4. ReverseEngineerCodeFirst 自定义模板

    1.在你要生成的项目里面在根目录下面添加CodeTemplates文件夹,并在该文件夹下面创建子文件夹ReverseEngineerCodeFirst 2.在ReverseEngineerCodeFi ...

  5. POJ 2823 线段树 Or 单调队列

    时限12s! 所以我用了线段树的黑暗做法,其实正解是用单调队列来做的. //By SiriusRen #include <cstdio> #include <cstring> ...

  6. C - Arrival of the General

    Problem description A Ministry for Defense sent a general to inspect the Super Secret Military Squad ...

  7. HTTPS的中那些加密算法

    密码学在计算机科学中使用非常广泛,HTTPS就是建立在密码学基础之上的一种安全的通信协议.HTTPS早在1994年由网景公司首次提出,而如今在众多互联网厂商的推广之下HTTPS已经被广泛使用在各种大小 ...

  8. 1C课程笔记分享_StudyJams_2017

    课程1C 概述 课程1C是创建一个生日贺卡应用的实践课程,所以本篇笔记分享主要记录个人的实践过程,此外分享一些比较零散的知识点. Drawable文件夹 Drawable文件夹是Android项目统一 ...

  9. 小功能__tab实录

    作为一个没有js基础的人来说,写一个小功能确实麻烦,也很累,从一个demo中发现details标签完美的实现菜单折叠功能,而不用费劲写好多li.div.js.发现html也是好厉害的.看来以后回家要多 ...

  10. Lazarus开发环境编译选项配置

    Lazarus的环境配置让人有点犯晕,对于刚从delphi转到lazarus上的我来说,每次新建工程都会遇到一堆Can't find unit xxxx used by xxxx的问题,问题虽然不大, ...