QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#17990#2213. Knightwxp#WA 15ms17992kbC++141.3kb2022-01-15 16:42:352022-05-04 16:35:56

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-04 16:35:56]
  • Judged
  • Verdict: WA
  • Time: 15ms
  • Memory: 17992kb
  • [2022-01-15 16:42:35]
  • Submitted

answer

#include<bits/stdc++.h>
#define rep(i,x,y) for(int i=x;i<=y;++i)
#define per(i,x,y) for(int i=x;i>=y;--i)
#define lon long long
using namespace std;
const int n7=1012;
const int dir[4][2]={{1,1},{1,-1},{-1,1},{-1,-1}};
int n,m,R,C,flag,typ[n7][n7],vis[n7][n7];
char a[n7][n7];

int rd(){
	int shu=0;bool fu=0;char ch=getchar();
	while( !isdigit(ch) ){if(ch=='-')fu=1;ch=getchar();}
	while( isdigit(ch) )shu=(shu<<1)+(shu<<3)+ch-'0',ch=getchar();
	return fu?-shu:shu;
}

void dfs(int x,int y){
	vis[x][y]=1,flag++;
	rep(k,0,3){
		int xx=x+dir[k][0]*R,yy=y+dir[k][1]*C;
		if(xx<1||xx>n||yy<1||yy>m||vis[xx][yy]||a[xx][yy]=='@')continue;
		typ[xx][yy]=!typ[x][y],dfs(xx,yy);
	}
	rep(k,0,3){
		int xx=x+dir[k][0]*C,yy=y+dir[k][1]*R;
		if(xx<1||xx>n||yy<1||yy>m||vis[xx][yy]||a[xx][yy]=='@')continue;
		typ[xx][yy]=!typ[x][y],dfs(xx,yy);
	}
}

int main(){
	n=rd(),m=rd(),R=rd(),C=rd();
	rep(i,1,n)scanf("%s",a[i]+1);
	memset(typ,-1,sizeof typ);
	rep(i,1,n)rep(j,1,m){
		if(a[i][j]=='A'){dfs(i,j);break;}
	}
	if(flag==1){puts("Bob");return 0;}
	rep(i,1,n)rep(j,1,m){
		if(a[i][j]=='B'){
			if(typ[i][j]==-1){puts("Alice");return 0;}
			if(typ[i][j]==0){puts("Alice");return 0;}
			if(typ[i][j]==1){puts("Bob");return 0;}
		}
	}
	return 0;
}

Details

Test #1:

score: 100
Accepted
time: 3ms
memory: 10608kb

Test #2:

score: 0
Accepted
time: 0ms
memory: 10536kb

Test #3:

score: 0
Accepted
time: 4ms
memory: 17992kb

Test #4:

score: -100
Wrong Answer
time: 15ms
memory: 16052kb