QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#421479#5070. Check Pattern is BadCrysflyWA 23ms3720kbC++171.9kb2024-05-25 19:51:142024-05-25 19:51:15

Judging History

你现在查看的是最新测评结果

  • [2024-05-25 19:51:15]
  • 评测
  • 测评结果:WA
  • 用时:23ms
  • 内存:3720kb
  • [2024-05-25 19:51:14]
  • 提交

answer

// what is matter? never mind. 
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx,avx,avx2") 
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define ll long long
#define int long long
#define ull unsigned long long
#define SZ(x) ((int)((x).size()))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
inline int read()
{
    char c=getchar();int x=0;bool f=0;
    for(;!isdigit(c);c=getchar())f^=!(c^45);
    for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
    if(f)x=-x;return x;
}

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;

#define maxn 505
#define inf 0x3f3f3f3f

int n,m;
char s[maxn][maxn];
int a[maxn][maxn];

void dfs(int x,int y){
	if(x<=0||y<=0||x>=n||y>=m)return;
	int s=a[x][y]+a[x+1][y]+a[x][y+1]+a[x+1][y+1];
	if(abs(s)==3){
		For(i,x,x+1) For(j,y,y+1) if(!a[i][j]){
			a[i][j]=-a[x+x+1-i][y+y+1-j];
			dfs(i,j);
			return;
		}
	}
}

void work()
{
	n=read(),m=read();
	For(i,1,n) cin>>(s[i]+1);
	For(i,1,n)For(j,1,m){
		if(s[i][j]=='?')a[i][j]=0;
		if(s[i][j]=='B')a[i][j]=1;
		if(s[i][j]=='W')a[i][j]=-1;
		if((i+j)%2)a[i][j]*=-1;
	}
	For(i,1,n-1)For(j,1,m-1)dfs(i,j);
	
	bool hav=0;
	For(x,1,n-1)For(y,1,m-1){
		int s=a[x][y]+a[x+1][y]+a[x][y+1]+a[x+1][y+1];
		if(abs(s)==4){
			puts("NO");
			return;
		}
	}
	
	For(i,1,n)
		For(j,1,m)
			if(!a[i][j]){
				a[i][j]=1;
				For(x,i-1,i)
					For(y,j-1,j)
						dfs(x,y);
			}
	puts("YES");
	For(i,1,n)
		For(j,1,m){
			if((i+j)%2)a[i][j]*=-1;
			if(a[i][j]==-1) cout<<"W";
			else cout<<"B";
			if(j==m)cout<<"\n";
		}
}

signed main()
{
	int T=read();
	while(T--)work();
	return 0;
}
/*
3
2 2
??
??
3 3
BW?
W?B
?BW
3 3
BW?
W?W
?W?
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3664kb

input:

3
2 2
??
??
3 3
BW?
W?B
?BW
3 3
BW?
W?W
?W?

output:

YES
BW
WW
NO
YES
BWB
WWW
BWB

result:

ok ok (3 test cases)

Test #2:

score: -100
Wrong Answer
time: 23ms
memory: 3720kb

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
BW
WW
BB
YES
BW
BB
BW
BW
WW
WB
NO
NO
YES
B
W
B
B
B
W
W
W
B
W
YES
BWWW
WWWB
WWWW
WBWW
WWWW
WWWW
WWWW
WWWW
BWBW
WWWW
YES
WBW
WBW
BBB
WBW
WWW
WBW
BBB
WWW
YES
W
B
B
W
YES
BBBB
WBWB
YES
BWBBBB
WWWBWB
YES
WWWWB
YES
BWBWBW
WWBBBB
BBBWBW
WBWWWW
YES
B
YES
BWB
BBB
WBB
WBB
WWB
WBB
BBW
WBW...

result:

wrong answer There is a check pattern in (0, 3) (test case 190)