QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#18015 | #2213. Knight | zrt# | WA | 12ms | 7484kb | C++11 | 1017b | 2022-01-15 18:30:43 | 2022-05-04 16:41:16 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int n,m,r,c;
char s[1010][1010];
int vis[1010][1010];
bool check(int x,int y){
if(x<=n&&x>=1&&y<=m&&y>=1&&!vis[x][y]&&s[x][y]!='@')return true;
return false;
}
void dfs(int x,int y,int v){
vis[x][y]=v;
if(check(x+r,y+c))dfs(x+r,y+c,v^1);
if(check(x+r,y-c))dfs(x+r,y-c,v^1);
if(check(x-r,y+c))dfs(x-r,y+c,v^1);
if(check(x-r,y-c))dfs(x-r,y-c,v^1);
swap(r,c);
if(check(x+r,y+c))dfs(x+r,y+c,v^1);
if(check(x+r,y-c))dfs(x+r,y-c,v^1);
if(check(x-r,y+c))dfs(x-r,y+c,v^1);
if(check(x-r,y-c))dfs(x-r,y-c,v^1);
swap(r,c);
return ;
}
int main(){
scanf("%d%d%d%d",&n,&m,&r,&c);
for(int i=1;i<=n;i++)
scanf("%s",s[i]+1);
int tot=1,cun1=0,cun2=0;
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++){
if(s[i][j]=='@')continue;
dfs(i,j,tot+=2);
if(s[i][j]=='A')cun1=vis[i][j];
if(s[i][j]=='B')cun2=vis[i][j];
}
if(cun1!=cun2&&cun1^1!=cun2){
puts("Alice");
}else if(cun1==cun2){
puts("Alice");
}else puts("Bob");
}
Details
Test #1:
score: 0
Wrong Answer
time: 12ms
memory: 7484kb