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

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

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. Protobuf支持 pointf

    Protobuf支持 pointf序列化 加入:ProtoBuf.Meta.RuntimeTypeModel.Default.Add(typeof(System.Drawing.PointF), fa ...

  2. iOS WKWebView OC 与 JS 交互学习

    我写WKWebView 想让 服务端相应 一个 方法但是不响应,根据 UIWebView 用 JSContext就能拿到响应的处理经验是不是服务端 也需要 对 WKwebView有兼容的一个写法??? ...

  3. OC自动释放池autoreleasepool介绍

    自动释放池的机制是:它使得应用在创建新对象时,系统能够有效地管理应用所使用的内存. @autoreleasepool { statements } 在创建新对象时,并且系统未启动ARC特性,那么在使用 ...

  4. Linux下运行java项目

    最近初步接触了linux,感觉很有新鲜感.之前在windows下干过的事情也便想到在linux环境下实现一下.正好手头在编java,就想既然java可以在windows的DOS操作下运行,是不是也可以 ...

  5. 012_Eclipse中使用 HDFS URL API 事例介绍

    本事例其实和使用hdfs FileSystem API差不多,FileSystem API也是通过解释成URL在hdfs上面执行的,性质相同,但是实际中用 的fFileSystem会多一点,源码如下: ...

  6. 【HackerRank】Closest Numbers

    Sorting is often useful as the first step in many different tasks. The most common task is to make f ...

  7. 一个不成熟的编程员,写写 js 的面向对象

    其实感觉本人 js 并未入门,甚至说也是个不合格的编程员,什么面向对象都不会,一直都往 Object 里面填方法,假装很对象的样子. 但学习嘛,这道坎还是得多试几下的,说不定就跨过去了呢. 个人喜欢用 ...

  8. Android 电容屏驱动

    Android 电容屏(一):电容屏基本原理篇 Android 电容屏(二):驱动调试之基本概念篇 Android 电容屏(三):驱动调试之驱动程序分析篇

  9. 快乐学习 Ionic Framework+PhoneGap 手册1-1{创建APP项目}

    快乐学习 Ionic Framework+PhoneGap 手册1-1 * 前提必须安装 Node.js,安装PhoneGap,搭建Android开发环境,建议使用真机调试 {1.1}= 创建APP项 ...

  10. block(data block,directory block)、inode、块位图、inode位图和super block概念详解【转】

    本文转载自:https://blog.csdn.net/jhndiuowehu/article/details/50788287 一.基本概念:      1.block:文件系统中存储数据的最小单元 ...