QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#864991#5070. Check Pattern is BadPlayVoltzWA 22ms3712kbC++142.2kb2025-01-21 13:16:372025-01-21 13:16:38

Judging History

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

  • [2025-01-21 13:16:38]
  • 评测
  • 测评结果:WA
  • 用时:22ms
  • 内存:3712kb
  • [2025-01-21 13:16:37]
  • 提交

answer

#include <cstdio>
#include <stdio.h>
#include <stdbool.h>
#include <iostream>
#include <map>
#include <vector>
#include <climits>
#include <stack>
#include <string>
#include <queue>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <cctype>
#include <bitset>
#include <iomanip>
#include <cstring>
#include <numeric>
#include <cassert>
using namespace std;

#define int long long
#define pii pair<int, int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second

int32_t main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin>>t;
	while (t--){
		int n, m;
		bool can=1;
		cin>>n>>m;
		char cc;
		vector<vector<int> > vect(n, vector<int>(m, 0));
		vector<vector<bool> > canw(n, vector<bool>(m, 1)), canb(n, vector<bool>(m, 1));
		for (int i=0; i<n; ++i)for (int j=0; j<m; ++j){
			cin>>cc;
			if (cc=='?')vect[i][j]=-1;
			else if (cc=='W')vect[i][j]=1;
		}
		for (int i=0; i<n-1; ++i)for (int j=0; j<m-1; ++j){
			if (vect[i][j]==1&&vect[i+1][j+1]==1&&!vect[i+1][j]&&!vect[i][j+1])can=0;
			if (!vect[i][j]&&!vect[i+1][j+1]&&vect[i+1][j]==1&&vect[i][j+1]==1)can=0;
			if (vect[i][j]==-1){
				if (vect[i+1][j+1]==1&&!vect[i+1][j]&&!vect[i][j+1])canw[i][j]=0;
				if (!vect[i+1][j+1]&&vect[i+1][j]==1&&vect[i][j+1]==1)canb[i][j]=0;
			}
			if (vect[i+1][j+1]==-1){
				if (vect[i][j]==1&&!vect[i+1][j]&&!vect[i][j+1])canw[i+1][j+1]=0;
				if (!vect[i][j]&&vect[i+1][j]==1&&vect[i][j+1]==1)canb[i+1][j+1]=0;
			}
			if (vect[i+1][j]==-1){
				if (vect[i][j]==1&&vect[i+1][j+1]==1&&!vect[i][j+1])canb[i+1][j]=0;
				if (!vect[i][j]&&!vect[i+1][j+1]&&vect[i][j+1]==1)canw[i+1][j]=0;
			}
			if (vect[i][j+1]==-1){
				if (vect[i][j]==1&&vect[i+1][j+1]==1&&!vect[i+1][j])canb[i][j+1]=0;
				if (!vect[i][j]&&!vect[i+1][j+1]&&vect[i+1][j]==1)canw[i][j+1]=0;
			}
		}
		for (int i=0; i<n; ++i)for (int j=0; j<m; ++j)if (vect[i][j]==-1&&!canw[i][j]&&!canb[i][j])can=0;
		if (!can){
			cout<<"NO\n";
			continue;
		}
		cout<<"YES\n";
		for (int i=0; i<n; ++i, cout<<"\n")for (int j=0; j<m; ++j){
			if (vect[i][j]!=-1)cout<<(vect[i][j]?'W':'B');
			else cout<<(canw[i][j]?'W':'B');
		}
	}
}

详细

Test #1:

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

input:

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

output:

YES
WW
WW
NO
YES
BWW
WWW
WWW

result:

ok ok (3 test cases)

Test #2:

score: -100
Wrong Answer
time: 22ms
memory: 3712kb

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
BW
WW
BB
YES
WW
WB
BW
BW
WW
WW
NO
NO
YES
B
W
W
B
B
W
W
W
B
W
YES
WWWW
WWWW
WWWW
WWWW
WWWW
WWWW
WWWW
WWWW
WWWW
WWWW
YES
WBW
WWW
WWW
WWW
WWW
WWW
WWW
WWW
YES
W
B
W
W
YES
WBWB
WWWB
YES
BWWBBB
WWWWWB
YES
WWWWW
YES
BWWWWW
WWBWWB
BBWWWW
WWWWWW
YES
W
YES
BWB
BBB
WBW
WBB
WWB
WBB
BWW
WWW...

result:

wrong answer There is a check pattern in (5, 0) (test case 1)