QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#18011#2213. KnightRealityang#WA 35ms17708kbC++141.4kb2022-01-15 18:04:072022-05-04 16:40:25

Judging History

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

  • [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:40:25]
  • 评测
  • 测评结果:WA
  • 用时:35ms
  • 内存:17708kb
  • [2022-01-15 18:04:07]
  • 提交

answer

#include<bits/stdc++.h>
//#define int long long
using namespace std;
const int N=1010,mod=1e9+7;
int n,vis[N][N],ri[N][N],m,r,c,ax,ay,bx,by;
int fx[9][2]={{-1,-1},{-1,1},{1,-1},{1,1},{-1,-1},{-1,1},{1,-1},{1,1}};
bool ac(int x,int y){
	if(x<1||y<1||x>n||y>m||ri[x][y]||vis[x][y])return false;
	return true;
}
void dfs(int x,int y,int co,int ad){
	vis[x][y]=co;
	for(int i=0;i<8;i++){
		int xx=x+fx[i][0],yy=y+fx[i][1];
		if(!ac(xx,yy))continue;
		if(!ad)dfs(xx,yy,co+1,1);
		else dfs(xx,yy,co-1,0);
	}
}
void A(){printf("Alice");exit(0);}
void B(){printf("Bob");exit(0);}
signed main(){
	scanf("%d%d%d%d",&n,&m,&r,&c);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			char s=getchar();while(s!='A'&&s!='B'&&s!='.'&&s!='@')s=getchar();
			if(s=='A')ax=i,ay=j;
			if(s=='B')bx=i,by=j;
			if(s=='@')ri[i][j]=1;
		}
	}int colo=1;
	for(int i=0;i<4;i++)fx[i][0]*=r,fx[i][1]*=c;
	for(int i=4;i<8;i++)fx[i][1]*=r,fx[i][0]*=c;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(vis[i][j]||ri[i][j])continue;
			vis[i][j]=++colo;
			dfs(i,j,colo,0);
			colo++;
		}
	}
	int rt=0;
	for(int i=0;i<8;i++){
		int xx=ax+fx[i][0],yy=ay+fx[i][1];
		if(xx<1||yy<1||xx>n||yy>m||ri[xx][yy]||(xx==bx&&yy==by))continue;
		rt=1;
	}
	if(!rt)B();
	if(vis[ax][ay]/2!=vis[bx][by]/2)A();
	if(vis[ax][ay]==vis[bx][by])B();
	else A();
}
/*
3 3 2 1
.A@
B..
@..
*/

Details

Test #1:

score: 100
Accepted
time: 11ms
memory: 11424kb

Test #2:

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

Test #3:

score: 0
Accepted
time: 35ms
memory: 17708kb

Test #4:

score: -100
Wrong Answer
time: 35ms
memory: 16624kb