QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#61026 | #2213. Knight | crazy_sea | WA | 9ms | 4872kb | C++11 | 783b | 2022-11-09 09:27:27 | 2022-11-09 09:27:30 |
Judging History
answer
#include<cstdio>
#include<vector>
using namespace std;
const int N=1e3+10;
char str[N];
int n,m,x1,y1,x2,y2,r,c;
bool vis[N][N],p[N][N],col[N][N];
vector<int> f1,f2;
bool chk(int x,int y)
{
if(x<1||y<1||x>n||y>m||p[x][y]) return 0;
return !vis[x][y];
}
void dfs(int x,int y)
{
vis[x][y]=1;
for(int i=0;i<8;i++)
if(chk(x+f1[i],y+f2[i]))
col[x+f1[i]][y+f2[i]]=!col[x][y],dfs(x+f1[i],y+f2[i]);
}
int main()
{
scanf("%d%d%d%d",&n,&m,&r,&c);
f1={-r,-c,c,r,r,c,-c,-r},f2={c,r,r,c,-c,-r,-r,-c};
for(int i=1;i<=n;i++)
{
scanf("%s",str);
for(int j=1;j<=m;j++)
if(str[j-1]=='A') x1=i,y1=j;
else if(str[j-1]=='B') x2=i,y2=j;
else if(str[j-1]=='@') p[i][j]=1;
}
dfs(x1,y1);
printf("%s",!vis[x2][y2]||col[x2][y2]==0?"Alice":"Bob");
}
Details
Test #1:
score: 0
Wrong Answer
time: 9ms
memory: 4872kb