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 ...
随机推荐
- MySQL数据库的集群方案
读写分离结构(主从) 读多写少,也就是对数据库读取数据的压力比较大. 其中一个是主库,负责写入数据,成为写库:其他都是从库,负责读取数据,成为读库. 对我们的要求: 读库和写库的数据一致: 写数据必须 ...
- 十大功能特性,助力开发者玩转API Explorer
摘要:华为云API Explorer为开发者提供一站式API解决方案统一平台,集成华为云服务所有开放API,支持全量快速检索.可视化调试.帮助文档.代码示例等能力,帮助开发者快速查找.学习API和使用 ...
- [译]使用Python和Dash 创建一个仪表盘(上)
介绍 在数据科学和分析的领域,数据能力的释放不仅是通过提取见解的方式, 同时也要能通过有效的方式来传达见解.这就是数据可视化发挥见解的地方. 数据可视化是信息和数据的可视化呈现. 它使用可视化元素,如 ...
- Unity的IPreprocessShaders:深入解析与实用案例
Unity IPreprocessShaders Unity IPreprocessShaders是Unity引擎中的一个非常有用的功能,它可以让开发者在编译Shader时自定义哪些操作需要被执行.这 ...
- NFS快速入门(一):简介、原理
NFS网络文件共享存储 什么是NFS NFS 是 Network File System 的缩写,中文意思是网络文件系统.它的主要功能是通过网络(一般是局域网)让不同主机系统之间可以共享文件或目录.N ...
- markdown之mermaid
官方文档 01 简单的流程图 TD或TB:top to bottom,从上到下的流程图 LR:从左到右 其它:RL,BT flowchart LR; A([节点A的圆矩框]) --> |AB之间 ...
- [nginx]proxy_cache缓存系统
前言 proxy_cache是nginx内置的一个缓存系统,可实现减小后端负载的作用. 常用参数说明 参数 说明 proxy_cache_path 缓存文件路径.level表示目录层级,1:2表示两个 ...
- PXE操作过程 kickstart 无人值守安装
PXE操作过程 分配给同一局域网内新加机器的地址(配置文件) dhcp 分配地址 指明tftp 服务器的地址 tftp服务端开启 udp 配置 默认关闭 安装syslinux 取得 pxelinux. ...
- Spring HandlerInterceptor工作机制
本文以一个通过正常注册拦截器流程注册拦截器失败的实际场景,来带领大家阅读源码,体会Spring的HandlerInterceptor拦截器整个工作流程 简单认识 org.springframework ...
- VINS中旋转外参初始化
VINS 中的旋转外参初始化 为了使这个两个传感器融合,我们首先需要做的事情是将两个传感器的数据对齐,除了时间上的对齐,还有空间上的对齐.空间上的对齐通俗的讲就是将一个传感器获取的数据统一到另一个 ...