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. 【题解】ABC293E Sol

    题目大意 给定整数 \(A,X,M\),求 \(\sum\limits^{X-1}_{i=0} A^i\) 对 \(M\) 取模的值. 数据范围:\(1 \le A,M \le 10^9\),\(1 ...

  2. node:spawn npm ENOENT

    错误背景 封装脚手架时报错 错误原因 windows系统原因 解决方案 const createProjectAction = async (project) => { console.log( ...

  3. windows传输文件到linux

    PFSTP 打开该软件,在安装putty自带的 连接服务器 open 192.168.142.131 按提示输入账户密码 传送文件 put C:\Users\13662\nifi-1.13.2-bin ...

  4. Topic太多,RocketMQ炸了!

    网上博客常说,kafka的topic数量过多会影响kafka,而RocketMQ不会受到topic数量影响. 但是,果真如此吗? 最近排查一个问题,发现RocketMQ稳定性同样受到topic数量影响 ...

  5. VS Code 有哪些好用的插件呢?【持续更新】

    一.画图工具:vscode-drawio   功能:在 VSCode 中画流程图.数据流图等等.        使用方法:     创建一个后缀名为 .drawio 的文件,然后用 VSCode 打开 ...

  6. tensorflow-2.7-M1-安装依赖openblas问题

    问题描述 安装过程 conda create -n conda-forge-tensorflow conda-forge::tensorflow conda info -e conda activat ...

  7. Azure Terraform(十四)Azure Key Vault 的机密管理

    一,引言 最近有网友私信我,将 Terraform 部署到 Azure 是一种将基础结构作为代码进行管理的好方法,但是如何使用 Azure Key Vault 来存储我们的 Secret ?在这篇博文 ...

  8. 基于Pair-wise和CrossEncoder训练单塔模型

    本文分享自华为云社区<语义检索系统排序模块:基于ERNIE-Gram的Pair-wise和基于RocketQA的CrossEncoder训练单塔模型>,作者: 汀丶. 文本匹配任务数据每一 ...

  9. Mybatis框架的搭建和基本使用

    本文总结最原始Mybatis框架的搭建和最基本使用(不涉及Spring框架体系). 1 依赖 首先,我们要引入Mybatis依赖: <dependency> <groupId> ...

  10. Redis专题-队列

    Redis专题-队列 首先,想一想 Redis 适合做消息队列吗? 1.消息队列的消息存取需求是什么?redis中的解决方案是什么? 无非就是下面这几点: 0.数据可以顺序读取 1.支持阻塞等待拉取消 ...