QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#451430 | #5070. Check Pattern is Bad | wyxqwq | WA | 15ms | 3800kb | C++14 | 2.6kb | 2024-06-23 12:50:47 | 2024-06-23 12:50:47 |
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();
}
}
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: 100
Accepted
time: 0ms
memory: 3796kb
input:
3 2 2 ?? ?? 3 3 BW? W?B ?BW 3 3 BW? W?W ?W?
output:
YES BW BB NO YES BWB WWW WWB
result:
ok ok (3 test cases)
Test #2:
score: -100
Wrong Answer
time: 15ms
memory: 3800kb
input:
10000 9 2 BB BW WW WW ?W ?B B? W? BB 6 2 ?? ?B B? BW WW ?? 10 7 WBBBW?? ???BWWW ???BWWB ??WWBW? BBWBBWB WWB?WW? BWBW??? WWWWBBW BBWBB?W B?W?W?B 4 7 ??WBWWB ?BBWWWB ?W?BBB? BBBWBBB 10 1 B W ? B B W W W B ? 10 4 ??WW W?W? WWW? ???W ?W?? ?W?W W?W? ?W?W ???W ???W 8 3 WBW W?? ??? ??? W?W W?W ??? ?W? 4 1 ...
output:
YES BB BW WW WW BW BB BB WW BB YES WW BB BW BW WW BB NO NO YES B W B B B W W W B W YES BWWW WWWW WWWB BWWW WWBW WWWW WBWW WWWW WBWW BBBW YES WBW WBW BBB WBW WBW WBW BBW BWW YES W B W W YES WBWB WWWB YES BWBBBB WWWBWB YES WWWWB YES BWBBBB WWBBWB BBBWWB WBWWWW YES W YES BWB BBB WBW WBB WWB BBB BWW WWW...
result:
wrong answer ans finds the answer, but out doesn't (test case 23)