QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#52104 | #2213. Knight | Constant# | WA | 1ms | 8312kb | C++14 | 1.0kb | 2022-10-04 10:27:05 | 2022-10-04 10:27:06 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define N 1005
using namespace std;
int vis[N][N],n,m,r,c,ax,ay,bx,by;
char s[N][N];
struct node
{
int x,y;
};
queue<node>q;
int main()
{
scanf("%d%d%d%d",&n,&m,&r,&c);
if(!r&&!c)
{
printf("Bob");
return 0;
}
memset(vis,-1,sizeof(vis));
int nt[8][2]={{r,c},{-r,c},{r,-c},{-r,-c},{c,r},{c,-r},{-c,r},{-c,-r}};
for(int i=1;i<=n;i++)
{
scanf("%s",s[i]+1);
for(int j=1;j<=m;j++)
{
if(s[i][j]=='A') ax=i,ay=j;
if(s[i][j]=='B') bx=i,by=j;
}
}
q.push((node){ax,ay});
vis[ax][ay]=1;
while(!q.empty())
{
node u=q.front();
q.pop();
for(int k=0;k<=7;k++)
{
int mx=u.x+nt[k][0],my=u.y+nt[k][1];
if(mx<1||my<1||mx>n||my>m) continue;
if(s[mx][my]=='@'||vis[mx][my]!=-1) continue;
vis[mx][my]=(vis[u.x][u.y]^1);
q.push((node){mx,my});
}
}
if(vis[bx][by]==-1)
{
printf("Alice");
return 0;
}
if(vis[ax][ay]==vis[bx][by]) printf("Alice");
else printf("Bob");
return 0;
}
Details
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 8312kb