CF1333A [Little Artem]
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]的更多相关文章
- codeforces 442C C. Artem and Array(贪心)
题目链接: C. Artem and Array time limit per test 2 seconds memory limit per test 256 megabytes input sta ...
- cf442C Artem and Array
C. Artem and Array time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces 442C Artem and Array(stack+贪婪)
题目连接:Codeforces 442C Artem and Array 题目大意:给出一个数组,每次删除一个数.删除一个数的得分为两边数的最小值,假设左右有一边不存在则算作0分. 问最大得分是多少. ...
- Codeforces 442C Artem and Array (看题解)
Artem and Array 经过分析我们能发现, 如果对于一个a[ i ] <= a[ i + 1 ] && a[ i ] <= a[ i - 1 ]可以直接删掉. 最 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- 手写call&apply&bind
在这里对call,apply,bind函数进行简单的封装 封装主要思想:给对象一个临时函数来调用,调用完毕后删除该临时函数对应的属性 call函数封装 function pliCall(fn, obj ...
- rsync 命令
linux上的rsync命令详解 15个rsync命令实施 -z: --compress 使用压缩机制 -v: --verbose 打印详细信息 -r: --recursive 以递归模式同步子目录 ...
- pandas 删除重复项
使用如下函数: drop_duplicates 具体示例如下: import pandas as pd # 建立一个dataframe数据 df = pd.DataFrame({'k1':['one' ...
- Blazor前后端框架Known-V1.2.11
V1.2.11 Known是基于C#和Blazor开发的前后端分离快速开发框架,开箱即用,跨平台,一处代码,多处运行. Gitee: https://gitee.com/known/Known Git ...
- grinder使用入门
安装配置 自动安装脚本编写 移步我的github下载脚本,只要修改下配置信息,即可完成安装 环境变量设置:
- Fabric 2.x 智能合约开发记录
表象:Return schema invalid. required items must be unique [recovered] 虽然 Fabric v2.2 已经发布了很久了,但之前因为项目历 ...
- EXE一机一码打包加密大师(EXE加密, 一机一码, 添加授权,添加静态密码,支持设置试用时间)
EXE一机一码打包加密大师可以打包加密保护EXE文件,同时给EXE文件添加上一机一码认证,或者静态密码,不同的电脑打开加密后的文件需要输入不同的激活码才能正常使用,保护文件安全,方便向用户收费. 下载 ...
- 开源通用型流式大数据统计系统XL-LightHouse介绍
概述 XL-LightHouse是针对互联网领域繁杂的流式数据统计需求而开发的一套集成了数据写入.数据运算.数据存储和数据可视化等一系列功能,支持大数据量,支持高并发的[通用型流式大数据统计平台]: ...
- html页面底部添加版权信息
话不多说,直接上代码: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:/ ...
- 3-MySQL基本数据类型介绍
数据类型的介绍: 数据类型(data_type)是指系统中所允许的数据的类型.数据库中的每个列都应有适当的数据类型,用于限制或允许该列中存储的数据.例如,列中存储的为数字,则相应的数据类型应该为数值类 ...