QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#462870#8742. 黑白275307894a#WA 46ms16308kbC++141.6kb2024-07-04 08:32:112024-07-04 08:32:11

Judging History

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

  • [2024-07-04 08:32:11]
  • 评测
  • 测评结果:WA
  • 用时:46ms
  • 内存:16308kb
  • [2024-07-04 08:32:11]
  • 提交

answer

#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define eb emplace_back
#define all(x) x.begin(),x.end()
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;
const int N=1e3+5,M=N*4+5,K=1000+5,mod=998244353,Mod=mod-1;const db eps=1e-9;const int INF=1e9+7;mt19937 rnd(time(0));
#define Tp template<typename T>
#define Ts template<typename T,typename... Ar>
namespace Debug{
	Tp void _debug(char* f,T t){cerr<<f<<'='<<t<<endl;}
	Ts void _debug(char* f,T x,Ar... y){while(*f!=',') cerr<<*f++;cerr<<'='<<x<<",";_debug(f+1,y...);}
	#ifdef LOCAL
	#define gdb(...) _debug((char*)#__VA_ARGS__,__VA_ARGS__)
	#else 
	#define gdb(...) void()
	#endif
}using namespace Debug;
int n,m,vis[N][N];char s[N][N];
void dfs(int x,int y){
	if(x<1||y<1||x>n||y>m||s[x][y]=='B'||vis[x][y]) return;
	vis[x][y]=1;
	dfs(x+1,y);dfs(x-1,y);dfs(x,y+1);dfs(x,y-1);
}
void Solve(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%s",s[i]+1);
	for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) vis[i][j]=0;
	dfs(1,1);
	if(!vis[n][m]){puts("J");return;}
	int cnt=0;
	for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) if(s[i][j]=='W') cnt++;
	puts(cnt-n-m&1?"I":"J");
}
int main(){
	int t=1;
	scanf("%d",&t);
	while(t--) Solve();
	cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

result:

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