Codeforces445A_DZY Loves Chessboard(预处理)
1 second
256 megabytes
standard input
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.
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 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.
1 1
.
B
2 2
..
..
BW
WB
3 3
.-.
---
--.
B-B
---
--B
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.
解题报告
预处理图,B和W相间。
输入“-”让mmap[i][j]='-'
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
char mmap[110][110];
int n,m;
int main()
{
int i,j;
while(~scanf("%d%d",&n,&m))
{
memset(mmap,0,sizeof(mmap));\
char c='B';
for(i=1; i<=n; i++)
{
if(i%2!=0)
c='B';
else c='W';
for(j=1; j<=m; j++)
{
mmap[i][j]=c;
if(c=='B')
c='W';
else c='B';
}
}
for(i=1;i<=n;i++)
{
for(j=1;j<=m;j++)
{
cin>>c;
if(c=='-')
mmap[i][j]=c;
}
}
for(i=1; i<=n; i++)
{
for(j=1; j<=m; j++)
cout<<mmap[i][j];
cout<<endl;
}
}
return 0;
}
Codeforces445A_DZY Loves Chessboard(预处理)的更多相关文章
- CodeForces445A DZY Loves Chessboard
A. DZY Loves Chessboard time limit per test 1 second memory limit per test 256 megabytes input stand ...
- 周赛-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 ...
- DZY Loves Chessboard
DescriptionDZY loves chessboard, and he enjoys playing with it. He has a chessboard of n rows and m ...
- cf445A DZY Loves Chessboard
A. DZY Loves Chessboard time limit per test 1 second memory limit per test 256 megabytes input stand ...
- 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 ...
- CF 445A DZY Loves Chessboard
A. DZY Loves Chessboard time limit per test 1 second memory limit per test 256 megabytes input stand ...
- Codeforces Round #254 (Div. 2) A. DZY Loves Chessboard —— dfs
题目链接: http://codeforces.com/problemset/problem/445/A 题解: 这道题是在现场赛的最后一分钟通过的,相当惊险,而且做的过程也很曲折. 先是用递推,结果 ...
- (CF)Codeforces445A DZY Loves Chessboard(纯实现题)
转载请注明出处:http://blog.csdn.net/u012860063? viewmode=contents 题目链接:http://codeforces.com/problemset/pro ...
- CodeForces - 445A - DZY Loves Chessboard
先上题目: A. DZY Loves Chessboard time limit per test 1 second memory limit per test 256 megabytes input ...
随机推荐
- EasyUi DataGrid 获取选中行的checkbox
EasyUi DataGrid 获取选中行的checkbox var checked = $(":checkbox[name=ID]:checked"); console.log( ...
- 大素数判断和素因子分解(miller-rabin,Pollard_rho算法)
#include<stdio.h> #include<string.h> #include<stdlib.h> #include<time.h> #in ...
- ZigBee学习五 无线温度检测
ZigBee学习五 无线温度检测 1)修改公用头文件GenericApp.h typedef union h{ uint8 TEMP[4]; struct RFRXBUF { unsigned cha ...
- BZOJ2121 字符串游戏 【dp】
题目链接 BZOJ2121 题解 dp怎么那么神呐QAQ 我们要求出最小字符串长度 我们设一个\(dp[i]\)表示前\(i\)个字符最后所形成的最短字符串长度 对于第\(i\)个字符,要么保留,就是 ...
- docker (centOS 7) 使用笔记5 - weave网络
weave官网 https://www.weave.works 1. 下载安装 sudo curl -L git.io/weave -o /usr/local/bin/weave sudo chmod ...
- powerdesign设置字体大小
http://www.2cto.com/database/201406/308923.html
- docke存储
1.Docker提供三种不同的方式将数据从宿主机挂载到容器中:volumes,bind mounts和tmpfs.volumes:Docker管理宿主机文件系统的一部分(/var/lib/docker ...
- hdu 1158 dp
/* 题目大意:给n个月工作需要的人数,雇佣一个需要花hire 每个月的薪水是salary,解雇一个需要fire 求完成所有工作的最小费用 dp(i,j)表示第i个月雇佣j员工的最小费用 */ #in ...
- 【CF1015F】Bracket Substring(字符串DP)
题意:给定一个只由左右括号组成的字符串s,问长度为2*n的包含它的合法括号序列方案数,答案对1e9+7取模 1≤n≤100,1≤|s|≤200 思路:暴力预处理出s的每个前缀[0..i]后加左右括号分 ...
- ThickBox弹出框的使用方法
原文发布时间为:2009-08-22 -- 来源于本人的百度文章 [由搬家工具导入] 请访问:http://www.blueidea.com/articleimg/2007/12/5182/tickb ...