QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#480376#8742. 黑白huaxiamengjinWA 77ms16648kbC++14946b2024-07-16 15:01:162024-07-16 15:01:17

Judging History

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

  • [2024-07-16 15:01:17]
  • 评测
  • 测评结果:WA
  • 用时:77ms
  • 内存:16648kb
  • [2024-07-16 15:01:16]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n,m;
char a[1010][1010];
bool used[1010][1010];
int dx[]={0,0,-1,1};
int dy[]={1,-1,0,0};
bool fl;
void dfs(int x,int y){
	if(used[x][y])return ;
	used[x][y]=1;
	int ct=0;
	for (int i=0;i<4;i++){
		int nx=x+dx[i];
		int ny=y+dy[i];
		if(nx<1||nx>n||ny<1||ny>m)continue;
		if(a[nx][ny]=='B')continue;
		ct++;dfs(nx,ny);
	}
	if(ct>2)fl=1;
	if(x==1&&y==1&&ct>1)fl=1;
	if(x==n&&y==m&&ct>1)fl=1;
}
void clear(){
	for (int i=1;i<=n;i++)
	for (int j=1;j<=m;j++)
	used[i][j]=0;
}
void solve(){
fl=0;
	cin>>n>>m;
	for (int i=1;i<=n;i++)
	for (int j=1;j<=m;j++)
	cin>>a[i][j];
	if(a[1][1]=='B'||a[n][m]=='B')
	return cout<<"J"<<"\n",void();
	dfs(1,1);
	if(used[n][m]==0)return cout<<"J\n",clear(); 
	if(fl==1)cout<<"I\n";
	else cout<<"J\n";
	return clear();
}
int main(){
	ios::sync_with_stdio(0); 
	cin.tie(0);cout.tie(0);
	int T;cin>>T;
	while(T--)solve();
}

详细

Test #1:

score: 0
Wrong Answer
time: 77ms
memory: 16648kb

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:

J
I
J
I
I
J
J
I
I
I
I
I
I
J
J
J
I
I
I
I
J
I
I
I
I
I
J
I
J
I
J
J
I
J
J
J
I
I
I
I
J
I
I
I
I
J
J
I
I
I
I
I
I
I
I
I
J
J
I
I
I
I
J
I
J
J
I
J
I
I
J
J
I
I
J
I
I
J
I
I
J
I
J
I
I
I
I
I
J
I
I
J
J
I
I
I
J
I
I
I

result:

wrong answer 2nd lines differ - expected: 'J', found: 'I'