QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#18016 | #2213. Knight | zrt# | WA | 7ms | 7844kb | C++11 | 1.0kb | 2022-01-15 18:32:36 | 2022-05-04 16:41:18 |
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;
if(!vis[i][j])dfs(i,j,tot+=2);
if(s[i][j]=='A')cun1=vis[i][j];
if(s[i][j]=='B')cun2=vis[i][j];
}
//cout<<cun1<<" "<<cun2<<endl;
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: 7ms
memory: 7844kb