QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#442366#8742. 黑白BeforeSun#WA 61ms6568kbC++141.1kb2024-06-15 11:25:212024-06-15 11:25:21

Judging History

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

  • [2024-06-15 11:25:21]
  • 评测
  • 测评结果:WA
  • 用时:61ms
  • 内存:6568kb
  • [2024-06-15 11:25:21]
  • 提交

answer

#include<bits/stdc++.h>
#define LL long long
using namespace std;
int T,n,m,s;
string Mp[1005];
string vis[1005];
bool check(int x,int y){
	return 1<=x&&x<=n&&1<=y&&y<=m&&Mp[x][y-1]=='W'&&vis[x][y-1]=='0';
}
bool bfs(){
	if(Mp[1][0]=='B'||Mp[n][m-1]=='B') return 0;
	queue<pair<int ,int> > q;
	q.push({1,1});
	vis[1][0]='1';
	while(q.size()){
		int hx=q.front().first,hy=q.front().second;
		q.pop();
		if(check(hx+1,hy)){
			q.push({hx+1,hy});
			vis[hx+1][hy-1]='1';
		}
		if(check(hx,hy+1)){
			q.push({hx,hy+1});
			vis[hx][hy]='1';
		}
		if(check(hx-1,hy)){
			q.push({hx-1,hy});
			vis[hx-1][hy-1]='1';
		}
		if(check(hx,hy-1)){
			q.push({hx,hy-1});
			vis[hx][hy-2]='1';
		}
	}
	return vis[n][m-1]=='1';
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cin>>T;
	while(T--){
		cin>>n>>m;
		s=n*m;
		s-=n+m-1;
		for(int i=1;i<=n;++i){
			cin>>Mp[i];
			vis[i].clear();
			for(int j=0;j<m;++j){
				if(Mp[i][j]=='B') s--;
				vis[i].push_back('0');
			}
		}
		if(!bfs()){
			cout<<'J';
			continue;
		}
		if(s&1) cout<<'I';
		else cout<<'J';
		cout<<'\n';
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 61ms
memory: 6568kb

input:

100
2 6
WWBBWW
WWWWWB
3 8
WWWBBBBB
WWWBWWWB
BBWWWBWW
5 2
WB
BB
BB
BW
BB
6 4
WWBW
WBWB
WWWW
WWWB
BBWW
BWBW
2 3
WWW
WBW
124 125
BWWWWWWWWWWWWWWWWWWWWWWWWWWBWWWWBWWWWWWWWBWWWWWWWWWWWBBBBWWWWWWWWWWWWWWWWWBWWWWWWWWWBWWWWWWWWWWBWWWWWWWWBBWWWWWWWWWWWWWWWWWWB
WWWWWWWBWWBWWWWWWWWWWWBWWBWWBWWWWBWWWWWWWWWBWBWB...

output:

JJ
JI
I
JI
I
I
J
I
J
J
JJJI
I
I
I
JJ
I
I
I
J
JI
J
J
J
JI
JJJJ
J
J
I
JJ
I
I
I
JJI
J
J
J
I
J
I
J
J
JJ
I
I
J
J
J
I
J
JI
JI
I
J
JJ
I
J
I
I
JJ
I
JJ
JJ
J
I
J
J
JI
I
JJI
I
J
J
J
J
I

result:

wrong answer 1st lines differ - expected: 'J', found: 'JJ'