QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#451431 | #5070. Check Pattern is Bad | wyxqwq | WA | 0ms | 3564kb | C++14 | 2.7kb | 2024-06-23 12:51:37 | 2024-06-23 12:51:38 |
Judging History
answer
#include<bits/stdc++.h>
#define vectorwyx maze
namespace vectorwyx{
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define sml(x,y) (x=min(x,y))
#define big(x,y) (x=max(x,y))
#define ll long long
#define uint unsigned
#define ull unsigned long long
#define umap unordered_map
#define db double
#define fo(i,x,y) for(int i=(x);i<=(y);++i)
#define go(i,x,y) for(int i=(x);i>=(y);--i)
#define ptc putchar
#define gtc getchar
#define emp emplace
#define re return
#define co continue
#define brk break
#define HH (ptc('\n'))
#define bctz __builtin_ctz
#define bclz __builtin_clz
#define bppc __builtin_popcount
using namespace std;
ll seed=chrono::system_clock::now().time_since_epoch().count();
mt19937 rnd(seed);
inline int rm(int x,int y){return (int)(rnd()%(y-x+1ll)+x);}
inline int read(){signed ch=getchar();int x=0,f=1;while(!isdigit(ch)){if(ch==(int)('-'))f=-1;ch=getchar();}while(isdigit(ch)){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}return x*f;}
template<typename T> void out(T *a,int l,int r){fo(i,l,r) cout<<*(a+i)<<' ';puts("");}
const int N=105;
int a[N][N],n,m;
int dx[]={1,-1,1,-1};
int dy[]={1,1,-1,-1};
bool do_it(int x,int y,int o){
// printf("do_it(%d,%d,%d)\n",x,y,o);
if(a[x][y]==-1) re 1;
int tx=x+dx[o],ty=y+dy[o];
if(a[tx][y]!=a[x][y]||a[x][ty]!=a[x][y]) re 1;
if(a[tx][ty]==a[x][y]) re 0;
a[tx][ty]=a[x][y]^1;
re do_it(tx,ty,o);
}
void solve(){
cin>>n>>m;
fo(i,0,n+1) fo(j,0,m+1) a[i][j]=-1;
fo(i,1,n){
signed ch=gtc();while(ch!='W'&&ch!='B'&&ch!='?') ch=gtc();
int id=1;
while(1){
if(ch=='W') a[i][id++]=0;
else if(ch=='B') a[i][id++]=1;
else if(ch=='?') a[i][id++]=-1;
else brk;
ch=gtc();
}
}
puts("NO");re;
fo(i,1,n) fo(j,1,m) if(a[i][j]>=0) a[i][j]^=((i+j)&1);
fo(i,1,n) fo(j,1,m) fo(k,0,3) if(!do_it(i,j,k)) goto H;
fo(i,1,n) fo(j,1,m) if(a[i][j]==-1){
a[i][j]=rm(0,1);
// printf("(%d,%d)\n",i,j);
fo(k,0,3) if(!do_it(i,j,k)) goto H;
if(!do_it(i-1,j,0)) goto H;
if(!do_it(i+1,j,1)) goto H;
if(!do_it(i,j-1,0)) goto H;
if(!do_it(i,j+1,2)) goto H;
}
fo(i,1,n) fo(j,1,m) if((i+j)&1) a[i][j]^=1;
puts("YES");
fo(i,1,n){
fo(j,1,m) ptc(a[i][j]?'B':'W');
puts("");
}
re;
H:puts("NO");
}
signed main(){
int T=read();
while(T--) solve();
return 0;
}
}
/*
-------------------------------------------------
*/
signed main(){re vectorwyx::main();}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3564kb
input:
3 2 2 ?? ?? 3 3 BW? W?B ?BW 3 3 BW? W?W ?W?
output:
NO NO NO
result:
wrong answer ans finds the answer, but out doesn't (test case 1)