QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#18064 | #2213. Knight | YLiF4# | WA | 23ms | 10596kb | C++14 | 956b | 2022-01-16 09:19:53 | 2022-05-04 17:00:54 |
Judging History
answer
#include<cstdio>
const int maxn=1010;
int a[maxn][maxn],n,m,r,c,siz;
char s[maxn][maxn];
void dfs(int x,int y,const int dir[8][2]){
siz++;
for(int i=0;i<8;i++){
int tx=x+dir[i][0],ty=y+dir[i][1];
if(tx<1||ty<1||tx>n||ty>m){
continue;
}
if(s[tx][ty]!='.'){
continue;
}
if(a[tx][ty]!=-1){
continue;
}
a[tx][ty]=1-a[x][y];
dfs(tx,ty,dir);
}
}
int main(){
scanf("%d%d%d%d",&n,&m,&r,&c);
const int dir[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++){
a[i][j]=-1;
}
}
int bx,by,ax,ay;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(s[i][j]=='A'){
a[i][j]=0;ax=i,ay=j;
dfs(i,j,dir);
}else if(s[i][j]=='B'){
bx=i,by=j;
}
}
}
if(siz==1){
puts("Bob");
return 0;
}
if(a[bx][by]==-1||a[ax][ay]==a[bx][by]){
puts("Alice");return 0;
}
puts("Bob");
return 0;
}
Details
Test #1:
score: 100
Accepted
time: 5ms
memory: 6284kb
Test #2:
score: 0
Accepted
time: 0ms
memory: 4436kb
Test #3:
score: 0
Accepted
time: 23ms
memory: 10596kb
Test #4:
score: 0
Accepted
time: 11ms
memory: 10188kb
Test #5:
score: 0
Accepted
time: 1ms
memory: 1824kb
Test #6:
score: 0
Accepted
time: 1ms
memory: 4112kb
Test #7:
score: 0
Accepted
time: 1ms
memory: 1816kb
Test #8:
score: 0
Accepted
time: 4ms
memory: 4636kb
Test #9:
score: 0
Accepted
time: 7ms
memory: 5604kb
Test #10:
score: 0
Accepted
time: 3ms
memory: 4720kb
Test #11:
score: 0
Accepted
time: 1ms
memory: 5736kb
Test #12:
score: 0
Accepted
time: 2ms
memory: 5852kb
Test #13:
score: -100
Wrong Answer
time: 8ms
memory: 7124kb