QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#421483#5070. Check Pattern is BadCrysflyWA 32ms3716kbC++172.2kb2024-05-25 19:53:512024-05-25 19:53:52

Judging History

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

  • [2024-05-25 19:53:52]
  • 评测
  • 测评结果:WA
  • 用时:32ms
  • 内存:3716kb
  • [2024-05-25 19:53:51]
  • 提交

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],aa[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;
		}
	}
}

bool hav4(){
	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)return 0;
	}
	return 1;
}

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]){
				For(x,1,n) For(y,1,n) aa[x][y]=a[x][y];
				a[i][j]=1;
				For(x,i-1,i)For(y,j-1,j)dfs(x,y);
				if(hav4()){
					For(x,1,n) For(y,1,n) a[x][y]=aa[x][y];
					a[i][j]=-1;
					For(x,i-1,i)For(y,j-1,j)dfs(x,y);
					if(hav4()){
						
					}
				}
			}
	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?
*/

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3704kb

input:

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

output:

YES
WB
BB
NO
YES
BWW
WWW
WWW

result:

ok ok (3 test cases)

Test #2:

score: -100
Wrong Answer
time: 32ms
memory: 3716kb

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
BB
BB
WW
BB
YES
WB
BB
BB
BW
WW
BW
NO
NO
YES
B
W
W
B
B
W
W
W
B
B
YES
WBWW
WWWW
WWWB
BWWW
WWWB
BWWW
WWWB
BWWW
WWWW
BWBW
YES
WBW
WWW
WBW
BBB
WBW
WWW
WBW
WWW
YES
W
B
W
B
YES
WBWB
WWWB
YES
BBWBBB
BWWWWB
YES
WBWBW
YES
BWWBWB
WWBBBB
BBBWWB
WWWWWW
YES
W
YES
BWB
BBB
WBW
BBB
WWB
BBB
BBW
BWW...

result:

wrong answer There is a check pattern in (2, 1) (test case 18)