QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#17994 | #2213. Knight | linmuhan# | AC ✓ | 111ms | 8776kb | C++11 | 912b | 2022-01-15 16:50:03 | 2022-05-04 16:36:09 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N=1005;
struct node{
int x,y,co;
};
int n,m,r,c,xa,ya,xb,yb;
int fx[4][2]={{1,1},{-1,1},{-1,-1},{1,-1}};
int k[N][N],t;
bool pd[N][N];
char ch;
queue<node> q;
int main () {
scanf("%d%d%d%d",&n,&m,&r,&c);
for(int i=1;i<=n;i++){
scanf("\n");
for(int j=1;j<=m;j++){
ch=getchar();
if(ch=='@') continue;
pd[i][j]=1;
if(ch=='A') xa=i,ya=j;
if(ch=='B') xb=i,yb=j;
}
}
q.push((node){xa,ya,2});k[xa][ya]=2;
while(!q.empty()){
node x=q.front();q.pop();t++;
for(int j=0;j<2;j++){
swap(r,c);
for(int i=0;i<4;i++){
int xx=x.x+fx[i][0]*r,yy=x.y+fx[i][1]*c;
if(xx<1||yy<1||xx>n||yy>m||k[xx][yy]||!pd[xx][yy]) continue;
k[xx][yy]=x.co^1;
q.push((node){xx,yy,x.co^1});
}
}
}
if(t==1) puts("Bob");
else if(!k[xb][yb]) puts("Alice");
else puts(k[xb][yb]&1?"Bob":"Alice");
}
Details
Test #1:
score: 100
Accepted
time: 9ms
memory: 6440kb
Test #2:
score: 0
Accepted
time: 1ms
memory: 6012kb
Test #3:
score: 0
Accepted
time: 20ms
memory: 7392kb
Test #4:
score: 0
Accepted
time: 12ms
memory: 7808kb
Test #5:
score: 0
Accepted
time: 0ms
memory: 3716kb
Test #6:
score: 0
Accepted
time: 1ms
memory: 6288kb
Test #7:
score: 0
Accepted
time: 2ms
memory: 5684kb
Test #8:
score: 0
Accepted
time: 0ms
memory: 6104kb
Test #9:
score: 0
Accepted
time: 0ms
memory: 6272kb
Test #10:
score: 0
Accepted
time: 1ms
memory: 8200kb
Test #11:
score: 0
Accepted
time: 4ms
memory: 6328kb
Test #12:
score: 0
Accepted
time: 11ms
memory: 8500kb
Test #13:
score: 0
Accepted
time: 4ms
memory: 6256kb
Test #14:
score: 0
Accepted
time: 6ms
memory: 8308kb
Test #15:
score: 0
Accepted
time: 3ms
memory: 7924kb
Test #16:
score: 0
Accepted
time: 11ms
memory: 8360kb
Test #17:
score: 0
Accepted
time: 3ms
memory: 5700kb
Test #18:
score: 0
Accepted
time: 5ms
memory: 6444kb
Test #19:
score: 0
Accepted
time: 3ms
memory: 3824kb
Test #20:
score: 0
Accepted
time: 7ms
memory: 6284kb
Test #21:
score: 0
Accepted
time: 1ms
memory: 5812kb
Test #22:
score: 0
Accepted
time: 7ms
memory: 6152kb
Test #23:
score: 0
Accepted
time: 3ms
memory: 5768kb
Test #24:
score: 0
Accepted
time: 9ms
memory: 6580kb
Test #25:
score: 0
Accepted
time: 5ms
memory: 4736kb
Test #26:
score: 0
Accepted
time: 2ms
memory: 5868kb
Test #27:
score: 0
Accepted
time: 1ms
memory: 5736kb
Test #28:
score: 0
Accepted
time: 24ms
memory: 7464kb
Test #29:
score: 0
Accepted
time: 0ms
memory: 6160kb
Test #30:
score: 0
Accepted
time: 0ms
memory: 6432kb
Test #31:
score: 0
Accepted
time: 5ms
memory: 5940kb
Test #32:
score: 0
Accepted
time: 3ms
memory: 3752kb
Test #33:
score: 0
Accepted
time: 21ms
memory: 7992kb
Test #34:
score: 0
Accepted
time: 6ms
memory: 8132kb
Test #35:
score: 0
Accepted
time: 18ms
memory: 7004kb
Test #36:
score: 0
Accepted
time: 8ms
memory: 7332kb
Test #37:
score: 0
Accepted
time: 4ms
memory: 6144kb
Test #38:
score: 0
Accepted
time: 10ms
memory: 6012kb
Test #39:
score: 0
Accepted
time: 0ms
memory: 5884kb
Test #40:
score: 0
Accepted
time: 5ms
memory: 6272kb
Test #41:
score: 0
Accepted
time: 5ms
memory: 6440kb
Test #42:
score: 0
Accepted
time: 1ms
memory: 6340kb
Test #43:
score: 0
Accepted
time: 4ms
memory: 4608kb
Test #44:
score: 0
Accepted
time: 5ms
memory: 6136kb
Test #45:
score: 0
Accepted
time: 1ms
memory: 6272kb
Test #46:
score: 0
Accepted
time: 3ms
memory: 6040kb
Test #47:
score: 0
Accepted
time: 4ms
memory: 6264kb
Test #48:
score: 0
Accepted
time: 22ms
memory: 8484kb
Test #49:
score: 0
Accepted
time: 4ms
memory: 6584kb
Test #50:
score: 0
Accepted
time: 3ms
memory: 6048kb
Test #51:
score: 0
Accepted
time: 78ms
memory: 8572kb
Test #52:
score: 0
Accepted
time: 27ms
memory: 8716kb
Test #53:
score: 0
Accepted
time: 7ms
memory: 6176kb
Test #54:
score: 0
Accepted
time: 41ms
memory: 8684kb
Test #55:
score: 0
Accepted
time: 25ms
memory: 8584kb
Test #56:
score: 0
Accepted
time: 60ms
memory: 8500kb
Test #57:
score: 0
Accepted
time: 51ms
memory: 8616kb
Test #58:
score: 0
Accepted
time: 10ms
memory: 6776kb
Test #59:
score: 0
Accepted
time: 7ms
memory: 4612kb
Test #60:
score: 0
Accepted
time: 68ms
memory: 8736kb
Test #61:
score: 0
Accepted
time: 16ms
memory: 6812kb
Test #62:
score: 0
Accepted
time: 8ms
memory: 8204kb
Test #63:
score: 0
Accepted
time: 97ms
memory: 8612kb
Test #64:
score: 0
Accepted
time: 16ms
memory: 8272kb
Test #65:
score: 0
Accepted
time: 7ms
memory: 8468kb
Test #66:
score: 0
Accepted
time: 18ms
memory: 6736kb
Test #67:
score: 0
Accepted
time: 38ms
memory: 8472kb
Test #68:
score: 0
Accepted
time: 8ms
memory: 8056kb
Test #69:
score: 0
Accepted
time: 66ms
memory: 8656kb
Test #70:
score: 0
Accepted
time: 33ms
memory: 8700kb
Test #71:
score: 0
Accepted
time: 9ms
memory: 7652kb
Test #72:
score: 0
Accepted
time: 5ms
memory: 6808kb
Test #73:
score: 0
Accepted
time: 6ms
memory: 6800kb
Test #74:
score: 0
Accepted
time: 77ms
memory: 8716kb
Test #75:
score: 0
Accepted
time: 11ms
memory: 7744kb
Test #76:
score: 0
Accepted
time: 15ms
memory: 7400kb
Test #77:
score: 0
Accepted
time: 75ms
memory: 8688kb
Test #78:
score: 0
Accepted
time: 9ms
memory: 8236kb
Test #79:
score: 0
Accepted
time: 4ms
memory: 6724kb
Test #80:
score: 0
Accepted
time: 111ms
memory: 8588kb
Test #81:
score: 0
Accepted
time: 9ms
memory: 8140kb
Test #82:
score: 0
Accepted
time: 7ms
memory: 7076kb
Test #83:
score: 0
Accepted
time: 10ms
memory: 8268kb
Test #84:
score: 0
Accepted
time: 2ms
memory: 7840kb
Test #85:
score: 0
Accepted
time: 4ms
memory: 6860kb
Test #86:
score: 0
Accepted
time: 3ms
memory: 8380kb
Test #87:
score: 0
Accepted
time: 18ms
memory: 8280kb
Test #88:
score: 0
Accepted
time: 4ms
memory: 6612kb
Test #89:
score: 0
Accepted
time: 58ms
memory: 8564kb
Test #90:
score: 0
Accepted
time: 10ms
memory: 6916kb
Test #91:
score: 0
Accepted
time: 13ms
memory: 6796kb
Test #92:
score: 0
Accepted
time: 35ms
memory: 8616kb
Test #93:
score: 0
Accepted
time: 16ms
memory: 4608kb
Test #94:
score: 0
Accepted
time: 110ms
memory: 8608kb
Test #95:
score: 0
Accepted
time: 4ms
memory: 8028kb
Test #96:
score: 0
Accepted
time: 9ms
memory: 8640kb
Test #97:
score: 0
Accepted
time: 93ms
memory: 8660kb
Test #98:
score: 0
Accepted
time: 86ms
memory: 8488kb
Test #99:
score: 0
Accepted
time: 18ms
memory: 7860kb
Test #100:
score: 0
Accepted
time: 12ms
memory: 7644kb
Test #101:
score: 0
Accepted
time: 10ms
memory: 8540kb
Test #102:
score: 0
Accepted
time: 11ms
memory: 8148kb
Test #103:
score: 0
Accepted
time: 94ms
memory: 8556kb
Test #104:
score: 0
Accepted
time: 16ms
memory: 8652kb
Test #105:
score: 0
Accepted
time: 9ms
memory: 8212kb
Test #106:
score: 0
Accepted
time: 3ms
memory: 6828kb
Test #107:
score: 0
Accepted
time: 79ms
memory: 8724kb
Test #108:
score: 0
Accepted
time: 83ms
memory: 8776kb
Test #109:
score: 0
Accepted
time: 77ms
memory: 8608kb
Test #110:
score: 0
Accepted
time: 46ms
memory: 8708kb
Test #111:
score: 0
Accepted
time: 48ms
memory: 8560kb
Test #112:
score: 0
Accepted
time: 12ms
memory: 7948kb
Test #113:
score: 0
Accepted
time: 12ms
memory: 8632kb
Test #114:
score: 0
Accepted
time: 4ms
memory: 6692kb
Test #115:
score: 0
Accepted
time: 5ms
memory: 8224kb
Test #116:
score: 0
Accepted
time: 17ms
memory: 8536kb
Test #117:
score: 0
Accepted
time: 12ms
memory: 8636kb
Test #118:
score: 0
Accepted
time: 13ms
memory: 6800kb
Test #119:
score: 0
Accepted
time: 6ms
memory: 6672kb
Test #120:
score: 0
Accepted
time: 91ms
memory: 8732kb
Test #121:
score: 0
Accepted
time: 12ms
memory: 8040kb
Test #122:
score: 0
Accepted
time: 0ms
memory: 8136kb
Test #123:
score: 0
Accepted
time: 6ms
memory: 4600kb
Test #124:
score: 0
Accepted
time: 11ms
memory: 6692kb
Test #125:
score: 0
Accepted
time: 54ms
memory: 8548kb
Test #126:
score: 0
Accepted
time: 5ms
memory: 8452kb
Test #127:
score: 0
Accepted
time: 6ms
memory: 8204kb
Test #128:
score: 0
Accepted
time: 6ms
memory: 7936kb
Test #129:
score: 0
Accepted
time: 1ms
memory: 6788kb
Test #130:
score: 0
Accepted
time: 16ms
memory: 8116kb
Test #131:
score: 0
Accepted
time: 9ms
memory: 6800kb
Test #132:
score: 0
Accepted
time: 74ms
memory: 8604kb
Test #133:
score: 0
Accepted
time: 6ms
memory: 8120kb
Test #134:
score: 0
Accepted
time: 15ms
memory: 6816kb
Test #135:
score: 0
Accepted
time: 83ms
memory: 8616kb
Test #136:
score: 0
Accepted
time: 12ms
memory: 6748kb
Test #137:
score: 0
Accepted
time: 20ms
memory: 7772kb
Test #138:
score: 0
Accepted
time: 77ms
memory: 8572kb
Test #139:
score: 0
Accepted
time: 14ms
memory: 6856kb
Test #140:
score: 0
Accepted
time: 16ms
memory: 8096kb
Test #141:
score: 0
Accepted
time: 21ms
memory: 8616kb
Test #142:
score: 0
Accepted
time: 7ms
memory: 6696kb
Test #143:
score: 0
Accepted
time: 68ms
memory: 8620kb
Test #144:
score: 0
Accepted
time: 20ms
memory: 8688kb
Test #145:
score: 0
Accepted
time: 55ms
memory: 8692kb
Test #146:
score: 0
Accepted
time: 15ms
memory: 7628kb
Test #147:
score: 0
Accepted
time: 21ms
memory: 8668kb
Test #148:
score: 0
Accepted
time: 66ms
memory: 8704kb
Test #149:
score: 0
Accepted
time: 28ms
memory: 8472kb
Test #150:
score: 0
Accepted
time: 54ms
memory: 8600kb
Test #151:
score: 0
Accepted
time: 53ms
memory: 8744kb
Test #152:
score: 0
Accepted
time: 8ms
memory: 6688kb
Test #153:
score: 0
Accepted
time: 17ms
memory: 6652kb
Test #154:
score: 0
Accepted
time: 16ms
memory: 4648kb
Test #155:
score: 0
Accepted
time: 92ms
memory: 8736kb
Test #156:
score: 0
Accepted
time: 17ms
memory: 6724kb
Test #157:
score: 0
Accepted
time: 3ms
memory: 6656kb
Test #158:
score: 0
Accepted
time: 11ms
memory: 6716kb
Test #159:
score: 0
Accepted
time: 7ms
memory: 4652kb
Test #160:
score: 0
Accepted
time: 15ms
memory: 8232kb
Test #161:
score: 0
Accepted
time: 46ms
memory: 8576kb
Test #162:
score: 0
Accepted
time: 11ms
memory: 8496kb
Test #163:
score: 0
Accepted
time: 12ms
memory: 7912kb
Test #164:
score: 0
Accepted
time: 49ms
memory: 8596kb
Test #165:
score: 0
Accepted
time: 45ms
memory: 8588kb
Test #166:
score: 0
Accepted
time: 90ms
memory: 8764kb