QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#52113 | #2213. Knight | Constant# | AC ✓ | 70ms | 8876kb | C++14 | 1.1kb | 2022-10-04 10:34:09 | 2022-10-04 10:34:10 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define N 1005
using namespace std;
int cnt,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);
if(!r&&!c)
{
printf("Bob");
return 0;
}
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]!=-1) continue;
cnt++;
vis[mx][my]=(vis[u.x][u.y]^1);
q.push((node){mx,my});
}
}
if(!cnt)
{
printf("Bob");
return 0;
}
if(vis[bx][by]==-1)
{
printf("Alice");
return 0;
}
if(vis[ax][ay]==vis[bx][by]) printf("Alice");
else printf("Bob");
return 0;
}
Details
Test #1:
score: 100
Accepted
time: 2ms
memory: 8392kb
Test #2:
score: 0
Accepted
time: 5ms
memory: 7976kb
Test #3:
score: 0
Accepted
time: 14ms
memory: 8360kb
Test #4:
score: 0
Accepted
time: 9ms
memory: 8380kb
Test #5:
score: 0
Accepted
time: 2ms
memory: 7636kb
Test #6:
score: 0
Accepted
time: 4ms
memory: 8252kb
Test #7:
score: 0
Accepted
time: 4ms
memory: 7656kb
Test #8:
score: 0
Accepted
time: 6ms
memory: 7980kb
Test #9:
score: 0
Accepted
time: 8ms
memory: 8344kb
Test #10:
score: 0
Accepted
time: 2ms
memory: 8400kb
Test #11:
score: 0
Accepted
time: 2ms
memory: 8236kb
Test #12:
score: 0
Accepted
time: 6ms
memory: 8500kb
Test #13:
score: 0
Accepted
time: 9ms
memory: 8168kb
Test #14:
score: 0
Accepted
time: 1ms
memory: 8680kb
Test #15:
score: 0
Accepted
time: 5ms
memory: 8456kb
Test #16:
score: 0
Accepted
time: 1ms
memory: 8520kb
Test #17:
score: 0
Accepted
time: 2ms
memory: 7580kb
Test #18:
score: 0
Accepted
time: 6ms
memory: 8196kb
Test #19:
score: 0
Accepted
time: 5ms
memory: 7948kb
Test #20:
score: 0
Accepted
time: 8ms
memory: 8228kb
Test #21:
score: 0
Accepted
time: 4ms
memory: 7544kb
Test #22:
score: 0
Accepted
time: 1ms
memory: 7948kb
Test #23:
score: 0
Accepted
time: 2ms
memory: 7724kb
Test #24:
score: 0
Accepted
time: 9ms
memory: 8584kb
Test #25:
score: 0
Accepted
time: 2ms
memory: 8560kb
Test #26:
score: 0
Accepted
time: 4ms
memory: 7756kb
Test #27:
score: 0
Accepted
time: 2ms
memory: 7748kb
Test #28:
score: 0
Accepted
time: 20ms
memory: 8472kb
Test #29:
score: 0
Accepted
time: 5ms
memory: 8112kb
Test #30:
score: 0
Accepted
time: 4ms
memory: 8580kb
Test #31:
score: 0
Accepted
time: 6ms
memory: 8100kb
Test #32:
score: 0
Accepted
time: 2ms
memory: 7856kb
Test #33:
score: 0
Accepted
time: 14ms
memory: 8420kb
Test #34:
score: 0
Accepted
time: 3ms
memory: 8296kb
Test #35:
score: 0
Accepted
time: 11ms
memory: 8252kb
Test #36:
score: 0
Accepted
time: 3ms
memory: 8632kb
Test #37:
score: 0
Accepted
time: 3ms
memory: 8124kb
Test #38:
score: 0
Accepted
time: 8ms
memory: 7744kb
Test #39:
score: 0
Accepted
time: 2ms
memory: 7968kb
Test #40:
score: 0
Accepted
time: 2ms
memory: 8144kb
Test #41:
score: 0
Accepted
time: 5ms
memory: 8260kb
Test #42:
score: 0
Accepted
time: 2ms
memory: 8260kb
Test #43:
score: 0
Accepted
time: 4ms
memory: 8528kb
Test #44:
score: 0
Accepted
time: 3ms
memory: 8104kb
Test #45:
score: 0
Accepted
time: 5ms
memory: 8260kb
Test #46:
score: 0
Accepted
time: 5ms
memory: 8116kb
Test #47:
score: 0
Accepted
time: 2ms
memory: 8064kb
Test #48:
score: 0
Accepted
time: 10ms
memory: 8752kb
Test #49:
score: 0
Accepted
time: 2ms
memory: 8304kb
Test #50:
score: 0
Accepted
time: 2ms
memory: 7956kb
Test #51:
score: 0
Accepted
time: 60ms
memory: 8696kb
Test #52:
score: 0
Accepted
time: 28ms
memory: 8800kb
Test #53:
score: 0
Accepted
time: 8ms
memory: 8644kb
Test #54:
score: 0
Accepted
time: 30ms
memory: 8652kb
Test #55:
score: 0
Accepted
time: 18ms
memory: 8740kb
Test #56:
score: 0
Accepted
time: 48ms
memory: 8756kb
Test #57:
score: 0
Accepted
time: 35ms
memory: 8756kb
Test #58:
score: 0
Accepted
time: 9ms
memory: 8604kb
Test #59:
score: 0
Accepted
time: 13ms
memory: 8660kb
Test #60:
score: 0
Accepted
time: 64ms
memory: 8780kb
Test #61:
score: 0
Accepted
time: 12ms
memory: 8600kb
Test #62:
score: 0
Accepted
time: 7ms
memory: 8712kb
Test #63:
score: 0
Accepted
time: 58ms
memory: 8676kb
Test #64:
score: 0
Accepted
time: 4ms
memory: 8752kb
Test #65:
score: 0
Accepted
time: 16ms
memory: 8528kb
Test #66:
score: 0
Accepted
time: 13ms
memory: 8600kb
Test #67:
score: 0
Accepted
time: 20ms
memory: 8604kb
Test #68:
score: 0
Accepted
time: 7ms
memory: 8656kb
Test #69:
score: 0
Accepted
time: 64ms
memory: 8728kb
Test #70:
score: 0
Accepted
time: 29ms
memory: 8672kb
Test #71:
score: 0
Accepted
time: 2ms
memory: 8656kb
Test #72:
score: 0
Accepted
time: 8ms
memory: 8660kb
Test #73:
score: 0
Accepted
time: 2ms
memory: 8756kb
Test #74:
score: 0
Accepted
time: 62ms
memory: 8768kb
Test #75:
score: 0
Accepted
time: 15ms
memory: 8640kb
Test #76:
score: 0
Accepted
time: 7ms
memory: 8668kb
Test #77:
score: 0
Accepted
time: 56ms
memory: 8672kb
Test #78:
score: 0
Accepted
time: 2ms
memory: 8756kb
Test #79:
score: 0
Accepted
time: 8ms
memory: 8740kb
Test #80:
score: 0
Accepted
time: 51ms
memory: 8760kb
Test #81:
score: 0
Accepted
time: 4ms
memory: 8660kb
Test #82:
score: 0
Accepted
time: 2ms
memory: 8644kb
Test #83:
score: 0
Accepted
time: 6ms
memory: 8520kb
Test #84:
score: 0
Accepted
time: 1ms
memory: 8752kb
Test #85:
score: 0
Accepted
time: 14ms
memory: 8640kb
Test #86:
score: 0
Accepted
time: 9ms
memory: 8764kb
Test #87:
score: 0
Accepted
time: 8ms
memory: 8668kb
Test #88:
score: 0
Accepted
time: 3ms
memory: 8776kb
Test #89:
score: 0
Accepted
time: 48ms
memory: 8680kb
Test #90:
score: 0
Accepted
time: 9ms
memory: 8736kb
Test #91:
score: 0
Accepted
time: 9ms
memory: 8604kb
Test #92:
score: 0
Accepted
time: 27ms
memory: 8696kb
Test #93:
score: 0
Accepted
time: 13ms
memory: 8756kb
Test #94:
score: 0
Accepted
time: 63ms
memory: 8712kb
Test #95:
score: 0
Accepted
time: 9ms
memory: 8600kb
Test #96:
score: 0
Accepted
time: 8ms
memory: 8712kb
Test #97:
score: 0
Accepted
time: 67ms
memory: 8876kb
Test #98:
score: 0
Accepted
time: 67ms
memory: 8764kb
Test #99:
score: 0
Accepted
time: 9ms
memory: 8752kb
Test #100:
score: 0
Accepted
time: 4ms
memory: 8524kb
Test #101:
score: 0
Accepted
time: 18ms
memory: 8756kb
Test #102:
score: 0
Accepted
time: 8ms
memory: 8664kb
Test #103:
score: 0
Accepted
time: 55ms
memory: 8752kb
Test #104:
score: 0
Accepted
time: 18ms
memory: 8752kb
Test #105:
score: 0
Accepted
time: 9ms
memory: 8532kb
Test #106:
score: 0
Accepted
time: 4ms
memory: 8764kb
Test #107:
score: 0
Accepted
time: 56ms
memory: 8716kb
Test #108:
score: 0
Accepted
time: 57ms
memory: 8688kb
Test #109:
score: 0
Accepted
time: 55ms
memory: 8684kb
Test #110:
score: 0
Accepted
time: 37ms
memory: 8736kb
Test #111:
score: 0
Accepted
time: 37ms
memory: 8668kb
Test #112:
score: 0
Accepted
time: 17ms
memory: 8780kb
Test #113:
score: 0
Accepted
time: 6ms
memory: 8736kb
Test #114:
score: 0
Accepted
time: 2ms
memory: 8756kb
Test #115:
score: 0
Accepted
time: 2ms
memory: 8752kb
Test #116:
score: 0
Accepted
time: 4ms
memory: 8604kb
Test #117:
score: 0
Accepted
time: 6ms
memory: 8680kb
Test #118:
score: 0
Accepted
time: 1ms
memory: 8656kb
Test #119:
score: 0
Accepted
time: 11ms
memory: 8600kb
Test #120:
score: 0
Accepted
time: 68ms
memory: 8820kb
Test #121:
score: 0
Accepted
time: 6ms
memory: 8656kb
Test #122:
score: 0
Accepted
time: 8ms
memory: 8664kb
Test #123:
score: 0
Accepted
time: 6ms
memory: 8748kb
Test #124:
score: 0
Accepted
time: 13ms
memory: 8748kb
Test #125:
score: 0
Accepted
time: 42ms
memory: 8740kb
Test #126:
score: 0
Accepted
time: 6ms
memory: 8520kb
Test #127:
score: 0
Accepted
time: 12ms
memory: 8744kb
Test #128:
score: 0
Accepted
time: 2ms
memory: 8600kb
Test #129:
score: 0
Accepted
time: 13ms
memory: 8740kb
Test #130:
score: 0
Accepted
time: 8ms
memory: 8764kb
Test #131:
score: 0
Accepted
time: 4ms
memory: 8748kb
Test #132:
score: 0
Accepted
time: 54ms
memory: 8704kb
Test #133:
score: 0
Accepted
time: 13ms
memory: 8732kb
Test #134:
score: 0
Accepted
time: 7ms
memory: 8660kb
Test #135:
score: 0
Accepted
time: 66ms
memory: 8800kb
Test #136:
score: 0
Accepted
time: 13ms
memory: 8524kb
Test #137:
score: 0
Accepted
time: 9ms
memory: 8756kb
Test #138:
score: 0
Accepted
time: 62ms
memory: 8620kb
Test #139:
score: 0
Accepted
time: 5ms
memory: 8764kb
Test #140:
score: 0
Accepted
time: 2ms
memory: 8768kb
Test #141:
score: 0
Accepted
time: 21ms
memory: 8768kb
Test #142:
score: 0
Accepted
time: 2ms
memory: 8520kb
Test #143:
score: 0
Accepted
time: 53ms
memory: 8576kb
Test #144:
score: 0
Accepted
time: 9ms
memory: 8668kb
Test #145:
score: 0
Accepted
time: 50ms
memory: 8532kb
Test #146:
score: 0
Accepted
time: 7ms
memory: 8744kb
Test #147:
score: 0
Accepted
time: 13ms
memory: 8692kb
Test #148:
score: 0
Accepted
time: 62ms
memory: 8624kb
Test #149:
score: 0
Accepted
time: 36ms
memory: 8668kb
Test #150:
score: 0
Accepted
time: 52ms
memory: 8752kb
Test #151:
score: 0
Accepted
time: 46ms
memory: 8772kb
Test #152:
score: 0
Accepted
time: 13ms
memory: 8664kb
Test #153:
score: 0
Accepted
time: 13ms
memory: 8604kb
Test #154:
score: 0
Accepted
time: 8ms
memory: 8660kb
Test #155:
score: 0
Accepted
time: 70ms
memory: 8796kb
Test #156:
score: 0
Accepted
time: 4ms
memory: 8604kb
Test #157:
score: 0
Accepted
time: 3ms
memory: 8652kb
Test #158:
score: 0
Accepted
time: 6ms
memory: 8656kb
Test #159:
score: 0
Accepted
time: 13ms
memory: 8664kb
Test #160:
score: 0
Accepted
time: 9ms
memory: 8652kb
Test #161:
score: 0
Accepted
time: 30ms
memory: 8684kb
Test #162:
score: 0
Accepted
time: 4ms
memory: 8660kb
Test #163:
score: 0
Accepted
time: 7ms
memory: 8520kb
Test #164:
score: 0
Accepted
time: 33ms
memory: 8616kb
Test #165:
score: 0
Accepted
time: 30ms
memory: 8684kb
Test #166:
score: 0
Accepted
time: 69ms
memory: 8720kb