QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#451429 | #5070. Check Pattern is Bad | wyxqwq | WA | 24ms | 3716kb | C++14 | 2.6kb | 2024-06-23 12:48:59 | 2024-06-23 12:48:59 |
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();}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3716kb
input:
3 2 2 ?? ?? 3 3 BW? W?B ?BW 3 3 BW? W?W ?W?
output:
YES BW BB NO YES BWW WWW WWW
result:
ok ok (3 test cases)
Test #2:
score: -100
Wrong Answer
time: 24ms
memory: 3588kb
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 WW WB BB WW BB YES BB WB BB BW WW BB NO NO YES B W W B B W W W B W YES BBWW WBWW WWWW BWWW BWBB BWWW WWWB BWWW WWWW BWBW YES WBW WWW BBW BBW WBW WWW BBB BWB YES W B W B YES BBBB WWWB YES BBWBBB WBWWWB YES WWWWB YES BWBBBW WWBBBB BBBWBW WBWWWW YES B YES BWB BBB WBB WBB WWB BBB BBW WWW...
result:
wrong answer ans finds the answer, but out doesn't (test case 18)