A. Little Artem
题目链接-A. Little Artem
题目大意
有一块
的木板,黑板上的每个单元格都应该涂上白色或黑色,设B是边上至少有一个白色方格相邻的黑色单元格的数量,W是边上至少有一个黑色方格相邻的白色单元格的数量,如果
,则称着色是好的,请你输出任意一个解决方案
解题思路
- 只需左上角的格子为 ,其他都为 即可
- 这样至少有一个黑色方格相邻的白色单元格的数量只有一个,而与它相邻的黑色方格数目有两个,刚好满足
- 具体操作见代码
附上代码
#pragma GCC optimize("-Ofast","-funroll-all-loops")
#pragma GCC diagnostic error "-std=c++11"
#include<bits/stdc++.h>
#define int long long
#define lowbit(x) (x &(-x))
#define endl '\n'
using namespace std;
const int INF=0x3f3f3f3f;
const int dir[4][2]={-1,0,1,0,0,-1,0,1};
const double PI=acos(-1.0);
const double e=exp(1.0);
const double eps=1e-10;
const int M=1e9+7;
const int N=1e5+10;
typedef long long ll;
typedef pair<int,int> PII;
typedef unsigned long long ull;
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
int t;
cin>>t;
while(t--){
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(i==1&&j==1)
cout<<"W";
else
cout<<"B";
}
cout<<endl;
}
}
return 0;
}