QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#18145 | #2213. Knight | Realityang# | AC ✓ | 111ms | 81332kb | C++14 | 1.4kb | 2022-01-16 15:33:18 | 2022-05-04 17:12:20 |
Judging History
answer
#include<bits/stdc++.h>
//#define int long long
using namespace std;
const int N=1010,mod=1e9+7;
int n,vis[N][N],ri[N][N],m,r,c,ax,ay,bx,by;
int fx[9][2]={{-1,-1},{-1,1},{1,-1},{1,1},{-1,-1},{-1,1},{1,-1},{1,1}};
bool ac(int x,int y){
if(x<1||y<1||x>n||y>m||ri[x][y]||vis[x][y])return false;
return true;
}
void dfs(int x,int y,int co,int ad){
vis[x][y]=co;
for(int i=0;i<8;i++){
int xx=x+fx[i][0],yy=y+fx[i][1];
if(!ac(xx,yy))continue;
if(!ad)dfs(xx,yy,co+1,1);
else dfs(xx,yy,co-1,0);
}
}
void A(){printf("Alice");exit(0);}
void B(){printf("Bob");exit(0);}
signed main(){
scanf("%d%d%d%d",&n,&m,&r,&c);
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
char s=getchar();while(s!='A'&&s!='B'&&s!='.'&&s!='@')s=getchar();
if(s=='A')ax=i,ay=j;
if(s=='B')bx=i,by=j;
if(s=='@')ri[i][j]=1;
}
}int colo=1;
for(int i=0;i<4;i++)fx[i][0]*=r,fx[i][1]*=c;
for(int i=4;i<8;i++)fx[i][1]*=r,fx[i][0]*=c;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(vis[i][j]||ri[i][j])continue;
vis[i][j]=++colo;
dfs(i,j,colo,0);
colo++;
}
}
int rt=0;
for(int i=0;i<8;i++){
int xx=ax+fx[i][0],yy=ay+fx[i][1];
if(xx<1||yy<1||xx>n||yy>m||ri[xx][yy]||(xx==bx&&yy==by)||(xx==ax&&yy==ay))continue;
rt=1;
}
if(!rt)B();
if(vis[ax][ay]/2!=vis[bx][by]/2)A();
if(vis[ax][ay]==vis[bx][by])A();
else B();
}
/*
3 3 2 1
.A@
B..
@..
*/
Details
Test #1:
score: 100
Accepted
time: 19ms
memory: 11348kb
Test #2:
score: 0
Accepted
time: 4ms
memory: 6712kb
Test #3:
score: 0
Accepted
time: 44ms
memory: 17572kb
Test #4:
score: 0
Accepted
time: 24ms
memory: 15268kb
Test #5:
score: 0
Accepted
time: 3ms
memory: 5916kb
Test #6:
score: 0
Accepted
time: 7ms
memory: 9864kb
Test #7:
score: 0
Accepted
time: 3ms
memory: 6004kb
Test #8:
score: 0
Accepted
time: 4ms
memory: 9996kb
Test #9:
score: 0
Accepted
time: 16ms
memory: 10896kb
Test #10:
score: 0
Accepted
time: 11ms
memory: 11412kb
Test #11:
score: 0
Accepted
time: 6ms
memory: 10620kb
Test #12:
score: 0
Accepted
time: 20ms
memory: 10820kb
Test #13:
score: 0
Accepted
time: 8ms
memory: 14552kb
Test #14:
score: 0
Accepted
time: 18ms
memory: 11436kb
Test #15:
score: 0
Accepted
time: 4ms
memory: 10896kb
Test #16:
score: 0
Accepted
time: 11ms
memory: 11108kb
Test #17:
score: 0
Accepted
time: 3ms
memory: 7964kb
Test #18:
score: 0
Accepted
time: 5ms
memory: 7672kb
Test #19:
score: 0
Accepted
time: 6ms
memory: 6628kb
Test #20:
score: 0
Accepted
time: 8ms
memory: 10220kb
Test #21:
score: 0
Accepted
time: 1ms
memory: 5792kb
Test #22:
score: 0
Accepted
time: 6ms
memory: 11164kb
Test #23:
score: 0
Accepted
time: 4ms
memory: 6184kb
Test #24:
score: 0
Accepted
time: 0ms
memory: 11404kb
Test #25:
score: 0
Accepted
time: 4ms
memory: 11536kb
Test #26:
score: 0
Accepted
time: 0ms
memory: 8140kb
Test #27:
score: 0
Accepted
time: 2ms
memory: 6072kb
Test #28:
score: 0
Accepted
time: 30ms
memory: 32980kb
Test #29:
score: 0
Accepted
time: 8ms
memory: 7220kb
Test #30:
score: 0
Accepted
time: 8ms
memory: 11432kb
Test #31:
score: 0
Accepted
time: 7ms
memory: 10240kb
Test #32:
score: 0
Accepted
time: 2ms
memory: 6164kb
Test #33:
score: 0
Accepted
time: 32ms
memory: 16696kb
Test #34:
score: 0
Accepted
time: 11ms
memory: 11684kb
Test #35:
score: 0
Accepted
time: 22ms
memory: 17396kb
Test #36:
score: 0
Accepted
time: 59ms
memory: 11976kb
Test #37:
score: 0
Accepted
time: 6ms
memory: 7188kb
Test #38:
score: 0
Accepted
time: 15ms
memory: 7964kb
Test #39:
score: 0
Accepted
time: 3ms
memory: 10596kb
Test #40:
score: 0
Accepted
time: 1ms
memory: 10112kb
Test #41:
score: 0
Accepted
time: 14ms
memory: 10668kb
Test #42:
score: 0
Accepted
time: 8ms
memory: 10288kb
Test #43:
score: 0
Accepted
time: 19ms
memory: 11188kb
Test #44:
score: 0
Accepted
time: 6ms
memory: 10260kb
Test #45:
score: 0
Accepted
time: 5ms
memory: 10080kb
Test #46:
score: 0
Accepted
time: 3ms
memory: 10296kb
Test #47:
score: 0
Accepted
time: 6ms
memory: 10264kb
Test #48:
score: 0
Accepted
time: 48ms
memory: 14700kb
Test #49:
score: 0
Accepted
time: 8ms
memory: 10796kb
Test #50:
score: 0
Accepted
time: 3ms
memory: 10080kb
Test #51:
score: 0
Accepted
time: 85ms
memory: 32792kb
Test #52:
score: 0
Accepted
time: 79ms
memory: 22112kb
Test #53:
score: 0
Accepted
time: 19ms
memory: 11700kb
Test #54:
score: 0
Accepted
time: 78ms
memory: 42592kb
Test #55:
score: 0
Accepted
time: 65ms
memory: 13636kb
Test #56:
score: 0
Accepted
time: 88ms
memory: 53076kb
Test #57:
score: 0
Accepted
time: 61ms
memory: 13516kb
Test #58:
score: 0
Accepted
time: 23ms
memory: 11780kb
Test #59:
score: 0
Accepted
time: 33ms
memory: 11744kb
Test #60:
score: 0
Accepted
time: 81ms
memory: 54560kb
Test #61:
score: 0
Accepted
time: 54ms
memory: 11780kb
Test #62:
score: 0
Accepted
time: 41ms
memory: 11740kb
Test #63:
score: 0
Accepted
time: 78ms
memory: 33136kb
Test #64:
score: 0
Accepted
time: 25ms
memory: 11784kb
Test #65:
score: 0
Accepted
time: 54ms
memory: 15752kb
Test #66:
score: 0
Accepted
time: 35ms
memory: 11624kb
Test #67:
score: 0
Accepted
time: 76ms
memory: 15076kb
Test #68:
score: 0
Accepted
time: 38ms
memory: 11740kb
Test #69:
score: 0
Accepted
time: 88ms
memory: 69416kb
Test #70:
score: 0
Accepted
time: 55ms
memory: 14728kb
Test #71:
score: 0
Accepted
time: 38ms
memory: 11588kb
Test #72:
score: 0
Accepted
time: 22ms
memory: 11780kb
Test #73:
score: 0
Accepted
time: 22ms
memory: 11700kb
Test #74:
score: 0
Accepted
time: 87ms
memory: 56840kb
Test #75:
score: 0
Accepted
time: 58ms
memory: 12176kb
Test #76:
score: 0
Accepted
time: 74ms
memory: 12344kb
Test #77:
score: 0
Accepted
time: 64ms
memory: 41560kb
Test #78:
score: 0
Accepted
time: 20ms
memory: 11712kb
Test #79:
score: 0
Accepted
time: 37ms
memory: 11748kb
Test #80:
score: 0
Accepted
time: 65ms
memory: 15356kb
Test #81:
score: 0
Accepted
time: 51ms
memory: 11716kb
Test #82:
score: 0
Accepted
time: 58ms
memory: 11768kb
Test #83:
score: 0
Accepted
time: 52ms
memory: 12444kb
Test #84:
score: 0
Accepted
time: 36ms
memory: 11692kb
Test #85:
score: 0
Accepted
time: 22ms
memory: 11716kb
Test #86:
score: 0
Accepted
time: 21ms
memory: 11716kb
Test #87:
score: 0
Accepted
time: 25ms
memory: 11784kb
Test #88:
score: 0
Accepted
time: 33ms
memory: 11584kb
Test #89:
score: 0
Accepted
time: 76ms
memory: 56104kb
Test #90:
score: 0
Accepted
time: 58ms
memory: 11876kb
Test #91:
score: 0
Accepted
time: 26ms
memory: 11784kb
Test #92:
score: 0
Accepted
time: 97ms
memory: 25812kb
Test #93:
score: 0
Accepted
time: 22ms
memory: 11728kb
Test #94:
score: 0
Accepted
time: 102ms
memory: 45692kb
Test #95:
score: 0
Accepted
time: 51ms
memory: 11776kb
Test #96:
score: 0
Accepted
time: 61ms
memory: 12068kb
Test #97:
score: 0
Accepted
time: 89ms
memory: 59628kb
Test #98:
score: 0
Accepted
time: 78ms
memory: 25348kb
Test #99:
score: 0
Accepted
time: 64ms
memory: 15356kb
Test #100:
score: 0
Accepted
time: 68ms
memory: 13092kb
Test #101:
score: 0
Accepted
time: 71ms
memory: 19188kb
Test #102:
score: 0
Accepted
time: 53ms
memory: 12044kb
Test #103:
score: 0
Accepted
time: 72ms
memory: 46372kb
Test #104:
score: 0
Accepted
time: 50ms
memory: 12192kb
Test #105:
score: 0
Accepted
time: 82ms
memory: 13388kb
Test #106:
score: 0
Accepted
time: 39ms
memory: 11780kb
Test #107:
score: 0
Accepted
time: 86ms
memory: 37504kb
Test #108:
score: 0
Accepted
time: 88ms
memory: 56836kb
Test #109:
score: 0
Accepted
time: 85ms
memory: 25964kb
Test #110:
score: 0
Accepted
time: 91ms
memory: 35544kb
Test #111:
score: 0
Accepted
time: 88ms
memory: 19436kb
Test #112:
score: 0
Accepted
time: 64ms
memory: 16636kb
Test #113:
score: 0
Accepted
time: 14ms
memory: 11516kb
Test #114:
score: 0
Accepted
time: 21ms
memory: 11728kb
Test #115:
score: 0
Accepted
time: 31ms
memory: 11752kb
Test #116:
score: 0
Accepted
time: 72ms
memory: 12844kb
Test #117:
score: 0
Accepted
time: 81ms
memory: 20032kb
Test #118:
score: 0
Accepted
time: 8ms
memory: 11784kb
Test #119:
score: 0
Accepted
time: 12ms
memory: 11712kb
Test #120:
score: 0
Accepted
time: 78ms
memory: 42548kb
Test #121:
score: 0
Accepted
time: 26ms
memory: 11784kb
Test #122:
score: 0
Accepted
time: 41ms
memory: 18568kb
Test #123:
score: 0
Accepted
time: 18ms
memory: 11720kb
Test #124:
score: 0
Accepted
time: 30ms
memory: 11740kb
Test #125:
score: 0
Accepted
time: 71ms
memory: 12816kb
Test #126:
score: 0
Accepted
time: 23ms
memory: 11580kb
Test #127:
score: 0
Accepted
time: 20ms
memory: 11724kb
Test #128:
score: 0
Accepted
time: 37ms
memory: 11720kb
Test #129:
score: 0
Accepted
time: 29ms
memory: 11692kb
Test #130:
score: 0
Accepted
time: 90ms
memory: 13808kb
Test #131:
score: 0
Accepted
time: 18ms
memory: 11624kb
Test #132:
score: 0
Accepted
time: 103ms
memory: 35176kb
Test #133:
score: 0
Accepted
time: 27ms
memory: 11668kb
Test #134:
score: 0
Accepted
time: 44ms
memory: 11516kb
Test #135:
score: 0
Accepted
time: 105ms
memory: 63364kb
Test #136:
score: 0
Accepted
time: 19ms
memory: 11732kb
Test #137:
score: 0
Accepted
time: 30ms
memory: 11620kb
Test #138:
score: 0
Accepted
time: 76ms
memory: 62188kb
Test #139:
score: 0
Accepted
time: 12ms
memory: 11616kb
Test #140:
score: 0
Accepted
time: 13ms
memory: 11620kb
Test #141:
score: 0
Accepted
time: 82ms
memory: 22580kb
Test #142:
score: 0
Accepted
time: 34ms
memory: 11724kb
Test #143:
score: 0
Accepted
time: 74ms
memory: 65668kb
Test #144:
score: 0
Accepted
time: 74ms
memory: 14716kb
Test #145:
score: 0
Accepted
time: 37ms
memory: 18272kb
Test #146:
score: 0
Accepted
time: 46ms
memory: 12268kb
Test #147:
score: 0
Accepted
time: 77ms
memory: 28528kb
Test #148:
score: 0
Accepted
time: 68ms
memory: 37076kb
Test #149:
score: 0
Accepted
time: 67ms
memory: 14928kb
Test #150:
score: 0
Accepted
time: 58ms
memory: 47236kb
Test #151:
score: 0
Accepted
time: 77ms
memory: 81332kb
Test #152:
score: 0
Accepted
time: 24ms
memory: 11740kb
Test #153:
score: 0
Accepted
time: 31ms
memory: 11784kb
Test #154:
score: 0
Accepted
time: 30ms
memory: 11624kb
Test #155:
score: 0
Accepted
time: 96ms
memory: 49708kb
Test #156:
score: 0
Accepted
time: 40ms
memory: 11696kb
Test #157:
score: 0
Accepted
time: 22ms
memory: 11728kb
Test #158:
score: 0
Accepted
time: 49ms
memory: 11712kb
Test #159:
score: 0
Accepted
time: 17ms
memory: 11708kb
Test #160:
score: 0
Accepted
time: 32ms
memory: 11620kb
Test #161:
score: 0
Accepted
time: 55ms
memory: 20108kb
Test #162:
score: 0
Accepted
time: 29ms
memory: 11668kb
Test #163:
score: 0
Accepted
time: 14ms
memory: 11708kb
Test #164:
score: 0
Accepted
time: 71ms
memory: 20044kb
Test #165:
score: 0
Accepted
time: 86ms
memory: 36816kb
Test #166:
score: 0
Accepted
time: 111ms
memory: 45256kb