QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#480339#8742. 黑白huaxiamengjinWA 46ms5624kbC++14716b2024-07-16 14:11:022024-07-16 14:11:02

Judging History

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

  • [2024-07-16 14:11:02]
  • 评测
  • 测评结果:WA
  • 用时:46ms
  • 内存:5624kb
  • [2024-07-16 14:11:02]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n,m;
char a[1010][1010];
bool f[1010][1010];
void solve(){
	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<<"L"<<"\n",void();
	f[1][1]=1;
	for (int i=1;i<=n;i++)
	for (int j=1;j<=m;j++)
	if((i!=1||j!=1)&&a[i][j]=='W')
	f[i][j]=f[i-1][j]|f[i][j-1];
	else if(a[i][j]=='B')f[i][j]=0;
	if(f[n][m]==0)return cout<<"L"<<"\n",void();
	int ct=0;
	for (int i=1;i<=n;i++)
	for (int j=1;j<=m;j++)
	ct+=(a[i][j]=='W');
	ct-=(n+m-1);
	if(ct&1)cout<<"I\n";
	else cout<<"J\n";
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int T;cin>>T;
	while(T--)solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 46ms
memory: 5624kb

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:

L
L
L
I
I
L
I
L
L
J
L
J
J
L
L
L
L
L
I
L
L
J
I
I
I
J
L
I
J
L
L
L
I
L
L
L
J
J
L
I
L
J
I
I
L
L
L
I
J
J
J
I
J
I
L
J
L
J
L
L
J
L
J
I
L
L
I
L
I
L
J
L
J
I
J
L
L
L
J
L
L
J
L
J
J
I
J
J
L
I
I
L
L
L
L
J
L
J
J
L

result:

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