Problem

题目简述

给你一个 \(n \times m\) 的方格,构造一个方案,使得方案中 \(B = W + 1\)。

\(B\):相邻的格子有至少一个白色格子的黑色格子的个数。

\(W\):相邻的格子有至少一个黑色格子的白色格子的个数。

思路

分奇偶讨论。

  • \(n \times m\) 是偶数:构造一张黑、白相间的矩阵,左上角填为白色,黑色方块的数量相同。

  • \(n \times m\) 是奇数:构造一张黑、白相间的矩阵,左上角填为黑色,黑白快数量相同。

代码

#include <bits/stdc++.h>

using namespace std;

int T, n, m;

int main() {

	scanf("%d", &T);
while (T--) {
scanf("%d%d", &n, &m);
if((n & 1) && (m & 1)) {
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= m; j++) {
if((i + j) & 1) printf("%c", 'W');
else printf("%c", 'B');
}
puts("");
}
}
else {
printf("%c", 'B');
for(int i = 2; i <= m; i++) {
if((i + 1) & 1) printf("%c", 'B');
else printf("%c", 'W');
}
puts("");
for(int i = 2; i <= n; i++) {
for(int j = 1; j <= m; j++) {
if((i + j) & 1) printf("%c", 'B');
else printf("%c", 'W');
}
puts("");
}
}
}
return 0;
}

CF1333A [Little Artem]的更多相关文章

  1. codeforces 442C C. Artem and Array(贪心)

    题目链接: C. Artem and Array time limit per test 2 seconds memory limit per test 256 megabytes input sta ...

  2. cf442C Artem and Array

    C. Artem and Array time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  3. Codeforces 442C Artem and Array(stack+贪婪)

    题目连接:Codeforces 442C Artem and Array 题目大意:给出一个数组,每次删除一个数.删除一个数的得分为两边数的最小值,假设左右有一边不存在则算作0分. 问最大得分是多少. ...

  4. Codeforces 442C Artem and Array (看题解)

    Artem and Array 经过分析我们能发现, 如果对于一个a[ i ] <= a[ i + 1 ] && a[ i ] <= a[ i - 1 ]可以直接删掉. 最 ...

  5. Codeforces Round #348 (VK Cup 2016 Round 2, Div. 1 Edition) C. Little Artem and Random Variable 数学

    C. Little Artem and Random Variable 题目连接: http://www.codeforces.com/contest/668/problem/C Descriptio ...

  6. Codeforces Round #348 (VK Cup 2016 Round 2, Div. 2 Edition) E. Little Artem and Time Machine 树状数组

    E. Little Artem and Time Machine 题目连接: http://www.codeforces.com/contest/669/problem/E Description L ...

  7. Codeforces Round #348 (VK Cup 2016 Round 2, Div. 2 Edition) D. Little Artem and Dance 模拟

    D. Little Artem and Dance 题目连接: http://www.codeforces.com/contest/669/problem/D Description Little A ...

  8. Codeforces Round #348 (VK Cup 2016 Round 2, Div. 2 Edition) C. Little Artem and Matrix 模拟

    C. Little Artem and Matrix 题目连接: http://www.codeforces.com/contest/669/problem/C Description Little ...

  9. Codeforces Round #348 (VK Cup 2016 Round 2, Div. 2 Edition) B. Little Artem and Grasshopper 模拟题

    B. Little Artem and Grasshopper 题目连接: http://www.codeforces.com/contest/669/problem/B Description Li ...

  10. Codeforces Round #348 (VK Cup 2016 Round 2, Div. 2 Edition) A. Little Artem and Presents 水题

    A. Little Artem and Presents 题目连接: http://www.codeforces.com/contest/669/problem/A Description Littl ...

随机推荐

  1. 【SpringCloud】Ribbon

    Ribbon 负载均衡原理 order-service 发起 user-service 请求,被ribbon进行拦截; ribbon会向注册中心拉取user-service 相对应的服务; 注册中心返 ...

  2. selenium 根据期刊信息获取知网文献信息 pt.1

    哈喽大家好,我是咸鱼 之前写过一篇获取知网文献信息的文章(关于<爬取知网文献信息>中代码的一些优化),看了下后台数据还挺不错 所以咸鱼决定再写一篇知网文献信息爬取的文章 需要注意的是文章只 ...

  3. 【Git】常用命令汇总

    一.仓库管理 git init:本地初始化 git clone:克隆远程仓库 git remote:远程仓库管理 git remote:查看远程仓库的信息 git remote -v:显示更详细的信息 ...

  4. Struts2 小知识点

    配置struts.xml文件,选择开发模式 在实际应用开发或者是产品部署的时候,对应着两种模式: 开发模式(devMode):此时 DevMode=ture: 产品模式(proMode):此时 Dev ...

  5. RabbitMQ 中 exchange、route、queue 的关系

    从 AMQP 协议可以看出,MessageQueue.Exchange 和 Binding 构成了 AMQP 协议的核心,下面我们就围绕这三个主要组件 从应用使用的角度全面的介绍如何利用 Rabbit ...

  6. 用 perfcollect 洞察 Linux 上.NET程序 CPU爆高

    一:背景 1. 讲故事 如果要分析 Linux上的 .NET程序 CPU 爆高,按以往的个性我肯定是抓个 dump 下来做事后分析,这种分析模式虽然不重但也不轻,还需要一定的底层知识,那有没有傻瓜式的 ...

  7. 说说 Linux 的 curl 命令

    cURL,熟悉 Linux 的同学,没有人不知道这个命令吧:) 它有非常非常多的参数,我这里就不复制粘贴了,有需要可以 -h 或者谷歌搜索看看. 我从实用性的角度,说下我比较常用的几个参数: -v:啰 ...

  8. python笔记:第十一章正则表达式

    1.模块re 以一定规则,快速检索文本,或是实现一些替换操作 默认下,区分大小写 2.常见的匹配字符表 字符 描述 \d 代表任意数字,就是阿拉伯数字 0-9 这些 \D 代表非数字的字符.与\d完全 ...

  9. 小白也能看懂的 ROC 曲线详解

    作者:PrimiHub-Kevin ROC 曲线是一种坐标图式的分析工具,是由二战中的电子和雷达工程师发明的,发明之初是用来侦测敌军飞机.船舰,后来被应用于医学.生物学.犯罪心理学. 如今,ROC 曲 ...

  10. C++之函数的分文件编写

    从黑马程序员的c++课里学到的函数的分文件编写 函数的分文件编写 作用:让代码结构更加清晰 函数分文件编写一般有4个步骤 1,创建后缀名为.h的头文件 2,创建后缀名为.cpp的源文件 3,在头文件中 ...