跳到正文

题解

1333A

gyh20约 1 分钟
原文
文章信息与版本

文章信息

收录
2026年6月14日
更新
2026年6月14日
篇幅
约 1 分钟
获赞
2
题目
CF1333A

版本

  1. v1当前

简要题意:构造一个 n×mn\times m 的矩阵使得其中有白色方格相邻的黑色方格比有黑色方格相邻的白色方格多一个。

可以发现,n,mn,m 都 >1>1,这样我们可以使最左边的一行全部为白,右边全部为黑,这样黑 == 白,然后将其中的一个白改为黑那么黑的答案不变,白的答案 −1-1,所以黑 == 白 +1+1。

C++
#include<bits/stdc++.h>
using namespace std;
#define re register
inline int read(){
	re int t=0;re char v=getchar();
	while(v<'0')v=getchar();
	while(v>='0')t=(t<<3)+(t<<1)+v-48,v=getchar();
	return t;
}
int n,a,b,m,t;
int main(){
	t=read();
	while(t--){
		n=read();m=read();
		for(re int i=1;i<=n;++i){
			for(re int j=1;j<=m;++j){
				if(j==1&&i!=n)putchar('W');
				else putchar('B');
			}puts("");
		}
	}
}
原文