QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#17982#2213. Knight_silhouette_#WA 116ms49936kbC++1.4kb2022-01-15 15:56:262022-05-04 16:34:41

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:34:41]
  • 评测
  • 测评结果:WA
  • 用时:116ms
  • 内存:49936kb
  • [2022-01-15 15:56:26]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int MAX=1e3;
const int fx[4]={1,1,-1,-1};
const int fy[4]={1,-1,1,-1};
int n,m,r,c,Num,tot,lin[MAX*MAX+5],vis[MAX*MAX+5],Dep[MAX*MAX+5];
char mp[MAX+5][MAX+5];
struct Edge{
	int Id,Next;
} e[MAX*MAX*16+5];
int Id(int x,int y){
	return (x-1)*m+y;
}
void Insert(int x,int y){
	e[++Num].Next=lin[x]; lin[x]=Num; e[Num].Id=y;
}
void dfs(int x){
	vis[x]=1; ++tot;
	for(int i=lin[x];i;i=e[i].Next){
		if(vis[e[i].Id]) continue;
		Dep[e[i].Id]=Dep[x]^1;
		dfs(e[i].Id);
	}
}
bool In(int x,int y){
	return x>=1&&x<=n&&y>=1&&y<=m;
}
int main(){
	scanf("%d%d%d%d",&n,&m,&r,&c);
	for(int i=1;i<=n;i++) scanf("%s",mp[i]+1);
	for(int i=1;i<=n;i++)
	 for(int j=1;j<=n;j++)
	  if(mp[i][j]!='@')
	   for(int k=0;k<4;k++){
	   	if(In(i+fx[k]*r,j+fy[k]*c)&&mp[i+fx[k]*r][j+fy[k]*c]!='@')
	   	 Insert(Id(i,j),Id(i+fx[k]*r,j+fy[k]*c)),
		 Insert(Id(i+fx[k]*r,j+fy[k]*c),Id(i,j)); 
		if(In(i+fx[k]*c,j+fy[k]*r)&&mp[i+fx[k]*c][j+fy[k]*r]!='@')
		 Insert(Id(i,j),Id(i+fx[k]*c,j+fy[k]*r)),
		 Insert(Id(i+fx[k]*c,j+fy[k]*r),Id(i,j)); 
	   }
	int sx=0,sy=0,ex=0,ey=0;
	for(int i=1;i<=n;i++)
	 for(int j=1;j<=m;j++){
		if(mp[i][j]=='A') sx=i,sy=j;
		if(mp[i][j]=='B') ex=i,ey=j;
	 }
	dfs(Id(sx,sy));
	if(tot==1) puts("Bob");
	else if(!vis[Id(ex,ey)]) puts("Alice");
	else {
		if(Dep[Id(ex,ey)]) puts("Bob");
		else puts("Alice");
	}
	return 0;
} 

Details

Test #1:

score: 100
Accepted
time: 6ms
memory: 23060kb

Test #2:

score: 0
Accepted
time: 5ms
memory: 9892kb

Test #3:

score: 0
Accepted
time: 86ms
memory: 42248kb

Test #4:

score: 0
Accepted
time: 46ms
memory: 31592kb

Test #5:

score: 0
Accepted
time: 2ms
memory: 11908kb

Test #6:

score: 0
Accepted
time: 3ms
memory: 14112kb

Test #7:

score: 0
Accepted
time: 5ms
memory: 9860kb

Test #8:

score: 0
Accepted
time: 8ms
memory: 11892kb

Test #9:

score: 0
Accepted
time: 7ms
memory: 17972kb

Test #10:

score: 0
Accepted
time: 9ms
memory: 16396kb

Test #11:

score: 0
Accepted
time: 11ms
memory: 14124kb

Test #12:

score: 0
Accepted
time: 3ms
memory: 30236kb

Test #13:

score: 0
Accepted
time: 14ms
memory: 20544kb

Test #14:

score: 0
Accepted
time: 17ms
memory: 26464kb

Test #15:

score: 0
Accepted
time: 15ms
memory: 14008kb

Test #16:

score: 0
Accepted
time: 13ms
memory: 15352kb

Test #17:

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

Test #18:

score: 0
Accepted
time: 10ms
memory: 19236kb

Test #19:

score: 0
Accepted
time: 3ms
memory: 10568kb

Test #20:

score: 0
Accepted
time: 11ms
memory: 16048kb

Test #21:

score: 0
Accepted
time: 2ms
memory: 7884kb

Test #22:

score: 0
Accepted
time: 5ms
memory: 11988kb

Test #23:

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

Test #24:

score: 0
Accepted
time: 7ms
memory: 14176kb

Test #25:

score: 0
Accepted
time: 16ms
memory: 16900kb

Test #26:

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

Test #27:

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

Test #28:

score: 0
Accepted
time: 116ms
memory: 49936kb

Test #29:

score: 0
Accepted
time: 5ms
memory: 11988kb

Test #30:

score: 0
Accepted
time: 8ms
memory: 16864kb

Test #31:

score: 0
Accepted
time: 11ms
memory: 19012kb

Test #32:

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

Test #33:

score: 0
Accepted
time: 112ms
memory: 42936kb

Test #34:

score: -100
Wrong Answer
time: 10ms
memory: 18536kb