Codeforces Round #254(div2)A
很有趣的题。想到了就非常简单,想不到就麻烦了。
其实就是一种逆向思维:最后结果肯定是这样子:
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的更多相关文章
- Codeforces Round #254(div2)B
就是看无向图有几个连通块,答案就是2n-num. 范围很小,就用矩阵来存图减少代码量. #include<iostream> #include<cstdio> #include ...
- Codeforces Round #539 div2
Codeforces Round #539 div2 abstract I 离散化三连 sort(pos.begin(), pos.end()); pos.erase(unique(pos.begin ...
- 【前行】◇第3站◇ Codeforces Round #512 Div2
[第3站]Codeforces Round #512 Div2 第三题莫名卡半天……一堆细节没处理,改一个发现还有一个……然后就炸了,罚了一啪啦时间 Rating又掉了……但是没什么,比上一次好多了: ...
- Codeforces Round 254 (Div. 2)
layout: post title: Codeforces Round 254 (Div. 2) author: "luowentaoaa" catalog: true tags ...
- Codeforces Round#320 Div2 解题报告
Codeforces Round#320 Div2 先做个标题党,骗骗访问量,结束后再来写咯. codeforces 579A Raising Bacteria codeforces 579B Fin ...
- Codeforces Round #564(div2)
Codeforces Round #564(div2) 本来以为是送分场,结果成了送命场. 菜是原罪 A SB题,上来读不懂题就交WA了一发,代码就不粘了 B 简单构造 很明显,\(n*n\)的矩阵可 ...
- Codeforces Round #361 div2
ProblemA(Codeforces Round 689A): 题意: 给一个手势, 问这个手势是否是唯一. 思路: 暴力, 模拟将这个手势上下左右移动一次看是否还在键盘上即可. 代码: #incl ...
- [Codeforces Round #254 div1] C.DZY Loves Colors 【线段树】
题目链接:CF Round #254 div1 C 题目分析 这道题目是要实现区间赋值的操作,同时还要根据区间中原先的值修改区间上的属性权值. 如果直接使用普通的线段树区间赋值的方法,当一个节点表示的 ...
- Codeforces Round #626 Div2 D,E
比赛链接: Codeforces Round #626 (Div. 2, based on Moscow Open Olympiad in Informatics) D.Present 题意: 给定大 ...
随机推荐
- loadrunder之脚本篇——加密解密
密码加密 可以给密码加密,意在把结果字符串作为脚本的参数或者参数值.例如,完整可能有一个用户密码填写的表单,你想测试网站针对不同密码的反应,但是你又想保护密码的安全.Password Encoder允 ...
- Raspberry Pi开发之旅-土壤湿度检测
一.土壤传感器 传感器四个针脚: 针脚 含义 AO 模拟信号输出 DO 数字信号输出 GND 电源负极 VCC 电源正极 二.接线 YL-38和YL69 之间直接用2根母对母线连接. YL-38和树 ...
- TIJ读书笔记01-操作符
TIJ读书笔记01-操作符 概述 关系操作符和逻辑操作符 位操作符 类型转换 概述 操作符 操作符接受一个或多个参数,并生成一个新值. 换句话说操作符作用于操作数,生成一个新值.有些操作符会改变操 ...
- BCM 交换机开发
转:http://blog.chinaunix.net/uid-23782786-id-3839602.html 前言: 最近搞这玩样,真是折腾,网上的资料都是片段,而且很少.折腾了4. ...
- 【Head First Servlets and JSP】笔记10:请求分派(RequestDispatcher)
1.让其它组件接管全部请求. package com.example.web; import com.example.model.BeerExpert; import javax.servlet.*; ...
- phpMyAdmin中config.inc.php设置密码和修改密码的方法
phpMyAdmin有3种授权模式: 1. cookie: 显示一个web登录页面,输入mysql的用户名和密码,然后进入管理界面. $cfg['Servers'][$i]['auth_type'] ...
- javax.servlet.jsp.JspException cannot be resolved to a type 和 javax.servlet.jsp.PageContext cannot be resolved to a type 解决办法
今天我从码云上拉一个项目下来,是个maven项目,闲来无事自己研究研究,发现刚拉下来,项目就有报错,我一看是httpServletRequest cannot be resolved to a typ ...
- Apache Phoenix的Join操作和优化
估计Phoenix中支持Joins,对很多使用Hbase的朋友来说,还是比较好的.下面我们就来演示一下. 首先看一下几张表的数据: Orders表: OrderID CustomerID ItemID ...
- PAT1028. List Sorting (25)
id用int,避免了id的strcmp,不然用string就超时. #include <iostream> #include <vector> #include <alg ...
- ZigzagConvert
public class ZigzagConvert { public static String convert(String s, int nRows) { int len = s.length( ...