很有趣的题。想到了就非常简单,想不到就麻烦了。

其实就是一种逆向思维:最后结果肯定是这样子:

WBWBWBWB...

BWBWBWBW...

WBWBWBWB...

...

里面有“-”的地方改成“-”就行了。

但是我开始是正着想的,想每个点怎么处理,这还要看它周围点的状态,越想越麻烦。。。

这题中体现的正难则反的逆向思维很值得学习。

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<stack>
#include<queue>
using namespace std;
#define INF 1000000000
#define eps 1e-8
#define pii pair<int,int>
#define LL long long int
int n,m;
char mp[][];
int main()
{
//freopen("in1.txt","r",stdin);
//freopen("out.txt","w",stdout);
scanf("%d%d",&n,&m);
getchar();
for(int i=; i<=n; i++)
{
for(int j=; j<=m; j++)
{
scanf("%c",&mp[i][j]);
}
getchar();
}
for(int i=;i<=n;i++)
{
for(int j=;j<=m;j++)
{
if(mp[i][j]=='-')
{
printf("-");
}
else
{
if((i+j)&)
{
printf("B");
}
else
printf("W");
}
}
printf("\n");
}
//fclose(stdin);
//fclose(stdout);
return ;
}

Codeforces Round #254(div2)A的更多相关文章

  1. Codeforces Round #254(div2)B

    就是看无向图有几个连通块,答案就是2n-num. 范围很小,就用矩阵来存图减少代码量. #include<iostream> #include<cstdio> #include ...

  2. Codeforces Round #539 div2

    Codeforces Round #539 div2 abstract I 离散化三连 sort(pos.begin(), pos.end()); pos.erase(unique(pos.begin ...

  3. 【前行】◇第3站◇ Codeforces Round #512 Div2

    [第3站]Codeforces Round #512 Div2 第三题莫名卡半天……一堆细节没处理,改一个发现还有一个……然后就炸了,罚了一啪啦时间 Rating又掉了……但是没什么,比上一次好多了: ...

  4. Codeforces Round 254 (Div. 2)

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

  5. Codeforces Round#320 Div2 解题报告

    Codeforces Round#320 Div2 先做个标题党,骗骗访问量,结束后再来写咯. codeforces 579A Raising Bacteria codeforces 579B Fin ...

  6. Codeforces Round #564(div2)

    Codeforces Round #564(div2) 本来以为是送分场,结果成了送命场. 菜是原罪 A SB题,上来读不懂题就交WA了一发,代码就不粘了 B 简单构造 很明显,\(n*n\)的矩阵可 ...

  7. Codeforces Round #361 div2

    ProblemA(Codeforces Round 689A): 题意: 给一个手势, 问这个手势是否是唯一. 思路: 暴力, 模拟将这个手势上下左右移动一次看是否还在键盘上即可. 代码: #incl ...

  8. [Codeforces Round #254 div1] C.DZY Loves Colors 【线段树】

    题目链接:CF Round #254 div1 C 题目分析 这道题目是要实现区间赋值的操作,同时还要根据区间中原先的值修改区间上的属性权值. 如果直接使用普通的线段树区间赋值的方法,当一个节点表示的 ...

  9. Codeforces Round #626 Div2 D,E

    比赛链接: Codeforces Round #626 (Div. 2, based on Moscow Open Olympiad in Informatics) D.Present 题意: 给定大 ...

随机推荐

  1. checked 和 unchecked 基元类型操作

    对基元类型执行的许多算术运算都可能造成溢出: Byte b = ; b = (Byte) (b + ); // b 现在包含 44(或者十六进制值 2C) 重要提示:执行上述算术运算时,第一步要求所有 ...

  2. ACM解题之快速输出杨辉三角形(前68行)

    题意: 本题要求计算并输出杨辉三角形的前 68 行. Time Limit:1000MS Memory Limit:65536K 解题: 为了能在规定时间准确输出杨辉三角形的前68行,这里我用了精准的 ...

  3. [转]c#中从string数组转换到int数组

    string[] input = { "1", "2", "3", "4", "5", " ...

  4. JavaScript:学习笔记(6)——New运算符

    JavaScript:学习笔记(6)——New运算符 new 运算符创建一个用户定义的对象类型的实例或具有构造函数的内置对象的实例. 快速开始 当你使用new关键字的时候,会 创建一个新的对象 将th ...

  5. Loadrunder脚本篇——web_custom_request做接口测试

    一.POST + JSON格式参数 例: web_custom_request("create", "URL=http://xxx.xxx.x.xx:1600/ditui ...

  6. iOS UIWindow 与 windowLevel 学习

    Pop几个关键点 KeyWindow :”The key window is the one that is designated to receive keyboard and other non- ...

  7. hadoop01

    RPC:异步系统的调用,webservice是RPC的一种.webservice用于不在同一个公司的系统调用,同一个公司用socket调用.就是RPC. Dubbo淘宝的RPC框架. Hadoop r ...

  8. yii异常处理架构

    使用方法: use \yii\base\ErrorException; try { exec("curl http://xxx",$out,$retno); if(0 !== $r ...

  9. Windos Server 2008 配置定时清理任务

    系统环境:Windos 2008 R2 x64 位 实施方案:自动清理超过两周的备份系统文件. 编写自动清理脚本..bat文件后缀. 打开计划任务

  10. Spring MVC 接收多个实体参数

    在SpringMVC 的接收参数中,如果接收一个实体对象,只需要在方法参数中这样做:@RequestBody User user //单个的时候这样接收 @RequestMapping(value = ...