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.
MD,今天写这道题目的时候,想的太简单了,被一类数据搞得体无完肤。。。
50 50
.........................--..................-....
............................................-.....
..-.....................................-.........
...........................-......................
........-.....................-...................
..................................................
.......-......-...................................
...-..................-.......................-...
.....-......-...............................-.....
...-................-...-..............
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...
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 ;
}
代码
CodeForces445A DZY Loves Chessboard的更多相关文章
- (CF)Codeforces445A DZY Loves Chessboard(纯实现题)
转载请注明出处:http://blog.csdn.net/u012860063? viewmode=contents 题目链接:http://codeforces.com/problemset/pro ...
- 周赛-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 题解: 这道题是在现场赛的最后一分钟通过的,相当惊险,而且做的过程也很曲折. 先是用递推,结果 ...
- CodeForces - 445A - DZY Loves Chessboard
先上题目: A. DZY Loves Chessboard time limit per test 1 second memory limit per test 256 megabytes input ...
- A. DZY Loves Chessboard
DZY loves chessboard, and he enjoys playing with it. He has a chessboard of n rows and m columns. So ...
随机推荐
- Python之路【第十八篇】Django小项目简单BBS论坛部分内容知识点
开发一个简单的BBS论坛 项目需求: 整体参考“抽屉新热榜” + “虎嗅网” 实现不同论坛版块 帖子列表展示 帖子评论数.点赞数展示 在线用户展示 允许登录用户发贴.评论.点赞 允许上传文件 帖子可被 ...
- 深入理解javascript原型和闭包(11)——执行上下文栈
继续上文的内容. 执行全局代码时,会产生一个执行上下文环境,每次调用函数都又会产生执行上下文环境.当函数调用完成时,这个上下文环境以及其中的数据都会被消除,再重新回到全局上下文环境.处于活动状态的执行 ...
- 5Hibernate配置及使用方法----青软S2SH(笔记)
关于hibernate的简单配置,先看结构图,我们需要 1.还要弄一下需要的 jar包. 2.配置两个文件(hibernate配置文件和映射文件),不过映射文件可以用注解替代. 3.写一个pojo类, ...
- vijos1250 最勇敢的机器人
背景 Wind设计了很多机器人.但是它们都认为自己是最强的,于是,一场比赛开始了~ 描述 机器人们都想知道谁是最勇敢的,于是它们比赛搬运一些物品. 它们到了一个仓库,里面有n个物品,每个物品都有一个价 ...
- Hadoop-HBASE案例分析-Hadoop学习笔记<二>
之前有幸在MOOC学院抽中小象学院hadoop体验课. 这是小象学院hadoop2.X概述第八章的笔记 主要介绍HBase,一个分布式数据库的应用案例. 案例概况: 1)时间序列数据库(OpenTSD ...
- NOSDK--一键打包的实现(四)
1.4 打包及签名的脚本介绍 我们使用ant来实现打包,这节我们先介绍脚本内容,关于脚本环境配置问题,我们将在下节做一个详细的介绍. 首先我们来看下build_android/tools/platfo ...
- unity3D游戏-WorldFight
计划写一个2D策略类的游戏,玩法类似炉石传说,以收集卡牌为主,不同的地方在于战斗方式类似棋类游戏,而且还有一个技能系统作为补充. ---更新(2015.7.13) v2.0.1更新: 添加了基本AI ...
- 常用的Mysql数据库操作语句大全
一.用户管理: 1.新建用户: >CREATE USER name IDENTIFIED BY 'ssapdrow'; 2.更改密码: >SET PASSWORD FOR name=PAS ...
- Python自动化之django的ORM操作——Python源码
""" The main QuerySet implementation. This provides the public API for the ORM. " ...
- Eclipse 设置SVN忽略文件
1.在 Eclipse 中点击菜单 window --> Preferences --> Team --> Ignored Resources 2.在Eclipse的导航视图中,选中 ...