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. TreeMap运行错误

    Exception in thread "main" java.lang.ClassCastException: Day16_TreeMap.Star cannot be cast ...

  2. Java扩展Nginx之五:五大handler(系列最核心)

    欢迎访问我的GitHub 这里分类和汇总了欣宸的全部原创(含配套源码):https://github.com/zq2599/blog_demos 本篇概览 本文是<Java扩展Nginx> ...

  3. CSRF与SSRF

    CSRF与SSRF CSRF(跨站请求伪造) 跨站请求伪造(Cross-site request forgery,CSRF),它强制终端用户在当前对其进行身份 验证后的Web应用程序上执行非本意的操作 ...

  4. 单节点kafka部署笔记

    1 背景 因为工作中需要对接kafka,准备在测试环境中自己部署一套,考虑方便决定部署一台单点. 2 部署 2.1 scala 2.1.1 java环境 openjdk即可,我使用的是openjdk1 ...

  5. 【技术积累】Vue中的核心概念【四】

    Vue的生命周期 Vue中的生命周期是指组件从创建到销毁的整个过程中,会触发一系列的钩子函数 Vue2中的生命周期 Vue2中的生命周期钩子函数是在组件的不同阶段执行的特定函数.这些钩子函数允许开发者 ...

  6. ubuntu安装msf签名认证失败

    添加命令 apt-get --allow-unauthenticated upgrade 来允许未认证签名软件安装,但是可能有恶意软件安装进来,可以使用 sudo apt-key adv --keys ...

  7. 2023-08-02:给定一棵树,一共有n个点, 每个点上没有值,请把1~n这些数字,不重复的分配到二叉树上, 做到 : 奇数层节点的值总和 与 偶数层节点的值总和 相差不超过1。 返回奇数层节点分配

    2023-08-02:给定一棵树,一共有n个点, 每个点上没有值,请把1~n这些数字,不重复的分配到二叉树上, 做到 : 奇数层节点的值总和 与 偶数层节点的值总和 相差不超过1. 返回奇数层节点分配 ...

  8. (转)IBM Appscan9.0.3安全扫描简单安装、使用以及高危漏洞修复

    最近手上负责一个的项目要进行等保评测.请的第三方公司采用IBM Security AppScan Standard对项目进行安全测试.测试报告高危漏洞主要包含sql注入.sql盲注.跨站点脚本编制如下 ...

  9. shell命令-lsof

    前言 lsof是系统管理常用命令,其名指的是list open files,列出打开的文件,而在linux系统,一切皆文件. centos7安装:yum install -y lsof 获取网络信息 ...

  10. 2023NepCTF-RE部分题解

    2023NepCTF-RE部分题解 九龙拉棺 过反调试 很容易发现 void __stdcall sub_401700() 里面有tea的痕迹 接出来发现只是前半部分 #include <std ...