QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#52087 | #2213. Knight | Constant# | WA | 10ms | 8256kb | C++14 | 970b | 2022-10-04 10:22:11 | 2022-10-04 10:22:14 |
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);
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]) 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("Bob");
else printf("Alice");
return 0;
}
Details
Test #1:
score: 0
Wrong Answer
time: 10ms
memory: 8256kb