1333A

· · 题解

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

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

#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("");
        }
    }
}