QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#18065 | #2213. Knight | YLiF4# | AC ✓ | 88ms | 62256kb | C++14 | 1.1kb | 2022-01-16 09:22:20 | 2022-05-04 17:00:56 |
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;
}
}
}
bool flg=false;
for(int i=0;i<8;i++){
int tx=ax+dir[i][0],ty=ay+dir[i][1];
if(tx<1||ty<1||tx>n||ty>m){
continue;
}
if(s[tx][ty]=='.'){
flg=true;break;
}
}
if(!flg){
puts("Bob");return 0;
}
if(a[bx][by]==-1||a[ax][ay]==a[bx][by]){
puts("Alice");return 0;
}
puts("Bob");
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 8ms
memory: 5728kb
Test #2:
score: 0
Accepted
time: 2ms
memory: 4152kb
Test #3:
score: 0
Accepted
time: 19ms
memory: 11584kb
Test #4:
score: 0
Accepted
time: 15ms
memory: 10032kb
Test #5:
score: 0
Accepted
time: 1ms
memory: 1816kb
Test #6:
score: 0
Accepted
time: 5ms
memory: 4580kb
Test #7:
score: 0
Accepted
time: 0ms
memory: 1820kb
Test #8:
score: 0
Accepted
time: 5ms
memory: 4612kb
Test #9:
score: 0
Accepted
time: 11ms
memory: 5984kb
Test #10:
score: 0
Accepted
time: 4ms
memory: 5396kb
Test #11:
score: 0
Accepted
time: 5ms
memory: 4676kb
Test #12:
score: 0
Accepted
time: 3ms
memory: 6020kb
Test #13:
score: 0
Accepted
time: 9ms
memory: 8852kb
Test #14:
score: 0
Accepted
time: 5ms
memory: 6248kb
Test #15:
score: 0
Accepted
time: 4ms
memory: 6364kb
Test #16:
score: 0
Accepted
time: 4ms
memory: 6468kb
Test #17:
score: 0
Accepted
time: 1ms
memory: 3700kb
Test #18:
score: 0
Accepted
time: 2ms
memory: 4752kb
Test #19:
score: 0
Accepted
time: 2ms
memory: 3688kb
Test #20:
score: 0
Accepted
time: 1ms
memory: 6028kb
Test #21:
score: 0
Accepted
time: 1ms
memory: 3624kb
Test #22:
score: 0
Accepted
time: 3ms
memory: 3964kb
Test #23:
score: 0
Accepted
time: 2ms
memory: 2060kb
Test #24:
score: 0
Accepted
time: 5ms
memory: 6128kb
Test #25:
score: 0
Accepted
time: 4ms
memory: 6372kb
Test #26:
score: 0
Accepted
time: 1ms
memory: 1972kb
Test #27:
score: 0
Accepted
time: 1ms
memory: 3616kb
Test #28:
score: 0
Accepted
time: 18ms
memory: 23448kb
Test #29:
score: 0
Accepted
time: 5ms
memory: 4872kb
Test #30:
score: 0
Accepted
time: 0ms
memory: 5760kb
Test #31:
score: 0
Accepted
time: 4ms
memory: 3972kb
Test #32:
score: 0
Accepted
time: 1ms
memory: 1912kb
Test #33:
score: 0
Accepted
time: 14ms
memory: 8564kb
Test #34:
score: 0
Accepted
time: 4ms
memory: 6336kb
Test #35:
score: 0
Accepted
time: 17ms
memory: 10124kb
Test #36:
score: 0
Accepted
time: 6ms
memory: 6648kb
Test #37:
score: 0
Accepted
time: 2ms
memory: 4904kb
Test #38:
score: 0
Accepted
time: 10ms
memory: 5536kb
Test #39:
score: 0
Accepted
time: 2ms
memory: 4492kb
Test #40:
score: 0
Accepted
time: 1ms
memory: 6136kb
Test #41:
score: 0
Accepted
time: 1ms
memory: 4512kb
Test #42:
score: 0
Accepted
time: 0ms
memory: 6180kb
Test #43:
score: 0
Accepted
time: 5ms
memory: 6232kb
Test #44:
score: 0
Accepted
time: 3ms
memory: 4004kb
Test #45:
score: 0
Accepted
time: 3ms
memory: 5804kb
Test #46:
score: 0
Accepted
time: 2ms
memory: 4024kb
Test #47:
score: 0
Accepted
time: 0ms
memory: 4588kb
Test #48:
score: 0
Accepted
time: 10ms
memory: 8812kb
Test #49:
score: 0
Accepted
time: 0ms
memory: 5348kb
Test #50:
score: 0
Accepted
time: 4ms
memory: 3928kb
Test #51:
score: 0
Accepted
time: 53ms
memory: 23800kb
Test #52:
score: 0
Accepted
time: 26ms
memory: 14768kb
Test #53:
score: 0
Accepted
time: 2ms
memory: 6548kb
Test #54:
score: 0
Accepted
time: 24ms
memory: 31464kb
Test #55:
score: 0
Accepted
time: 15ms
memory: 8080kb
Test #56:
score: 0
Accepted
time: 78ms
memory: 39840kb
Test #57:
score: 0
Accepted
time: 38ms
memory: 8296kb
Test #58:
score: 0
Accepted
time: 7ms
memory: 6444kb
Test #59:
score: 0
Accepted
time: 0ms
memory: 6440kb
Test #60:
score: 0
Accepted
time: 73ms
memory: 41828kb
Test #61:
score: 0
Accepted
time: 6ms
memory: 6528kb
Test #62:
score: 0
Accepted
time: 13ms
memory: 6516kb
Test #63:
score: 0
Accepted
time: 56ms
memory: 22544kb
Test #64:
score: 0
Accepted
time: 10ms
memory: 6516kb
Test #65:
score: 0
Accepted
time: 6ms
memory: 9644kb
Test #66:
score: 0
Accepted
time: 13ms
memory: 6552kb
Test #67:
score: 0
Accepted
time: 15ms
memory: 9056kb
Test #68:
score: 0
Accepted
time: 1ms
memory: 6516kb
Test #69:
score: 0
Accepted
time: 78ms
memory: 51704kb
Test #70:
score: 0
Accepted
time: 14ms
memory: 8816kb
Test #71:
score: 0
Accepted
time: 2ms
memory: 6508kb
Test #72:
score: 0
Accepted
time: 11ms
memory: 6588kb
Test #73:
score: 0
Accepted
time: 4ms
memory: 6544kb
Test #74:
score: 0
Accepted
time: 73ms
memory: 43832kb
Test #75:
score: 0
Accepted
time: 17ms
memory: 6760kb
Test #76:
score: 0
Accepted
time: 4ms
memory: 6900kb
Test #77:
score: 0
Accepted
time: 56ms
memory: 29248kb
Test #78:
score: 0
Accepted
time: 7ms
memory: 6548kb
Test #79:
score: 0
Accepted
time: 2ms
memory: 6512kb
Test #80:
score: 0
Accepted
time: 43ms
memory: 9136kb
Test #81:
score: 0
Accepted
time: 6ms
memory: 6560kb
Test #82:
score: 0
Accepted
time: 1ms
memory: 6580kb
Test #83:
score: 0
Accepted
time: 13ms
memory: 6436kb
Test #84:
score: 0
Accepted
time: 4ms
memory: 6440kb
Test #85:
score: 0
Accepted
time: 5ms
memory: 6536kb
Test #86:
score: 0
Accepted
time: 5ms
memory: 6532kb
Test #87:
score: 0
Accepted
time: 4ms
memory: 6588kb
Test #88:
score: 0
Accepted
time: 12ms
memory: 6552kb
Test #89:
score: 0
Accepted
time: 80ms
memory: 40836kb
Test #90:
score: 0
Accepted
time: 10ms
memory: 6524kb
Test #91:
score: 0
Accepted
time: 5ms
memory: 6500kb
Test #92:
score: 0
Accepted
time: 17ms
memory: 17672kb
Test #93:
score: 0
Accepted
time: 9ms
memory: 6520kb
Test #94:
score: 0
Accepted
time: 53ms
memory: 33964kb
Test #95:
score: 0
Accepted
time: 7ms
memory: 6528kb
Test #96:
score: 0
Accepted
time: 9ms
memory: 6588kb
Test #97:
score: 0
Accepted
time: 70ms
memory: 44872kb
Test #98:
score: 0
Accepted
time: 61ms
memory: 16660kb
Test #99:
score: 0
Accepted
time: 19ms
memory: 7716kb
Test #100:
score: 0
Accepted
time: 7ms
memory: 7364kb
Test #101:
score: 0
Accepted
time: 11ms
memory: 12500kb
Test #102:
score: 0
Accepted
time: 9ms
memory: 6804kb
Test #103:
score: 0
Accepted
time: 54ms
memory: 36248kb
Test #104:
score: 0
Accepted
time: 12ms
memory: 6852kb
Test #105:
score: 0
Accepted
time: 11ms
memory: 7788kb
Test #106:
score: 0
Accepted
time: 4ms
memory: 6440kb
Test #107:
score: 0
Accepted
time: 69ms
memory: 27596kb
Test #108:
score: 0
Accepted
time: 60ms
memory: 42176kb
Test #109:
score: 0
Accepted
time: 58ms
memory: 17028kb
Test #110:
score: 0
Accepted
time: 29ms
memory: 25260kb
Test #111:
score: 0
Accepted
time: 39ms
memory: 12792kb
Test #112:
score: 0
Accepted
time: 9ms
memory: 10772kb
Test #113:
score: 0
Accepted
time: 4ms
memory: 6504kb
Test #114:
score: 0
Accepted
time: 9ms
memory: 6536kb
Test #115:
score: 0
Accepted
time: 7ms
memory: 6592kb
Test #116:
score: 0
Accepted
time: 3ms
memory: 7416kb
Test #117:
score: 0
Accepted
time: 16ms
memory: 13232kb
Test #118:
score: 0
Accepted
time: 7ms
memory: 6528kb
Test #119:
score: 0
Accepted
time: 5ms
memory: 6504kb
Test #120:
score: 0
Accepted
time: 56ms
memory: 30984kb
Test #121:
score: 0
Accepted
time: 13ms
memory: 6444kb
Test #122:
score: 0
Accepted
time: 3ms
memory: 6520kb
Test #123:
score: 0
Accepted
time: 0ms
memory: 6536kb
Test #124:
score: 0
Accepted
time: 14ms
memory: 6528kb
Test #125:
score: 0
Accepted
time: 29ms
memory: 7404kb
Test #126:
score: 0
Accepted
time: 9ms
memory: 6520kb
Test #127:
score: 0
Accepted
time: 9ms
memory: 6512kb
Test #128:
score: 0
Accepted
time: 2ms
memory: 6528kb
Test #129:
score: 0
Accepted
time: 5ms
memory: 6428kb
Test #130:
score: 0
Accepted
time: 17ms
memory: 8264kb
Test #131:
score: 0
Accepted
time: 12ms
memory: 6552kb
Test #132:
score: 0
Accepted
time: 67ms
memory: 25100kb
Test #133:
score: 0
Accepted
time: 7ms
memory: 6596kb
Test #134:
score: 0
Accepted
time: 2ms
memory: 6440kb
Test #135:
score: 0
Accepted
time: 88ms
memory: 47080kb
Test #136:
score: 0
Accepted
time: 5ms
memory: 6448kb
Test #137:
score: 0
Accepted
time: 1ms
memory: 6548kb
Test #138:
score: 0
Accepted
time: 62ms
memory: 47748kb
Test #139:
score: 0
Accepted
time: 4ms
memory: 6508kb
Test #140:
score: 0
Accepted
time: 12ms
memory: 6552kb
Test #141:
score: 0
Accepted
time: 16ms
memory: 14592kb
Test #142:
score: 0
Accepted
time: 12ms
memory: 6556kb
Test #143:
score: 0
Accepted
time: 72ms
memory: 50156kb
Test #144:
score: 0
Accepted
time: 9ms
memory: 8908kb
Test #145:
score: 0
Accepted
time: 36ms
memory: 13832kb
Test #146:
score: 0
Accepted
time: 9ms
memory: 6896kb
Test #147:
score: 0
Accepted
time: 16ms
memory: 19912kb
Test #148:
score: 0
Accepted
time: 58ms
memory: 28180kb
Test #149:
score: 0
Accepted
time: 21ms
memory: 8464kb
Test #150:
score: 0
Accepted
time: 59ms
memory: 34148kb
Test #151:
score: 0
Accepted
time: 72ms
memory: 62256kb
Test #152:
score: 0
Accepted
time: 7ms
memory: 6440kb
Test #153:
score: 0
Accepted
time: 12ms
memory: 6544kb
Test #154:
score: 0
Accepted
time: 13ms
memory: 6572kb
Test #155:
score: 0
Accepted
time: 55ms
memory: 37104kb
Test #156:
score: 0
Accepted
time: 11ms
memory: 6552kb
Test #157:
score: 0
Accepted
time: 9ms
memory: 6600kb
Test #158:
score: 0
Accepted
time: 9ms
memory: 6548kb
Test #159:
score: 0
Accepted
time: 13ms
memory: 6524kb
Test #160:
score: 0
Accepted
time: 12ms
memory: 6540kb
Test #161:
score: 0
Accepted
time: 37ms
memory: 13188kb
Test #162:
score: 0
Accepted
time: 1ms
memory: 6528kb
Test #163:
score: 0
Accepted
time: 7ms
memory: 6540kb
Test #164:
score: 0
Accepted
time: 20ms
memory: 13344kb
Test #165:
score: 0
Accepted
time: 43ms
memory: 25964kb
Test #166:
score: 0
Accepted
time: 59ms
memory: 33044kb