QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#432866#8742. 黑白LiWenX#WA 197ms8524kbC++20885b2024-06-07 19:17:572024-06-07 19:17:57

Judging History

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

  • [2024-06-07 19:17:57]
  • 评测
  • 测评结果:WA
  • 用时:197ms
  • 内存:8524kb
  • [2024-06-07 19:17:57]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n,m;
char ch[1005][1005];
int dis[1005][1005];
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
void solve(){
	cin>>n>>m;
	int s=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cin>>ch[i][j];
			dis[i][j]=-1;
			if(ch[i][j]=='W') s++;
		}
	}
	queue<pair<int,int> > q;
	q.push(make_pair(1,1));
	dis[1][1]=1;
	while(!q.empty()){
		pair<int,int> now=q.front();q.pop();
		for(int i=0;i<4;i++){
			pair<int,int> nxt=now;
			nxt.first+=dx[i];
			nxt.second+=dy[i];
			int x=nxt.first,y=nxt.second;
			if(x<1||x>n||y<1||y>m) continue;
			if(dis[x][y]!=-1) continue;
			dis[x][y]=dis[now.first][now.second]+1;
			q.push(nxt);
		}
	}
	if(dis[n][m]==-1){
		cout<<"J\n";
		return ;
	}
	s-=dis[n][m];
	if(s&1) cout<<"I\n";
	else cout<<"J\n";
}
int main(){
	int tt;cin>>tt;
	while(tt--){
		solve();
	}
}

详细

Test #1:

score: 0
Wrong Answer
time: 197ms
memory: 8524kb

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
J
J
I
I
J
I
I
I
J
I
J
J
I
J
I
I
I
I
I
I
J
I
I
I
J
J
I
J
J
J
J
I
I
I
J
J
J
J
I
J
J
I
I
I
I
J
I
J
J
J
I
J
I
J
J
J
J
I
I
J
J
J
I
J
I
I
I
I
I
J
I
J
I
J
I
I
I
J
I
J
J
J
J
J
I
J
J
I
I
I
J
J
I
I
J
J
J
J
I

result:

wrong answer 14th lines differ - expected: 'J', found: 'I'