QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#17986 | #2213. Knight | _silhouette_# | AC ✓ | 517ms | 137476kb | C++ | 1.4kb | 2022-01-15 16:02:58 | 2022-05-04 16:35:00 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int MAX=1e3;
const int fx[4]={1,1,-1,-1};
const int fy[4]={1,-1,1,-1};
int n,m,r,c,Num,tot,lin[MAX*MAX+5],vis[MAX*MAX+5],Dep[MAX*MAX+5];
char mp[MAX+5][MAX+5];
struct Edge{
int Id,Next;
} e[MAX*MAX*32+5];
int Id(int x,int y){
return (x-1)*m+y;
}
void Insert(int x,int y){
e[++Num].Next=lin[x]; lin[x]=Num; e[Num].Id=y;
}
void dfs(int x){
vis[x]=1; ++tot;
for(int i=lin[x];i;i=e[i].Next){
if(vis[e[i].Id]) continue;
Dep[e[i].Id]=Dep[x]^1;
dfs(e[i].Id);
}
}
bool In(int x,int y){
return x>=1&&x<=n&&y>=1&&y<=m;
}
int main(){
scanf("%d%d%d%d",&n,&m,&r,&c);
for(int i=1;i<=n;i++) scanf("%s",mp[i]+1);
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
if(mp[i][j]!='@')
for(int k=0;k<4;k++){
if(In(i+fx[k]*r,j+fy[k]*c)&&mp[i+fx[k]*r][j+fy[k]*c]!='@')
Insert(Id(i,j),Id(i+fx[k]*r,j+fy[k]*c)),
Insert(Id(i+fx[k]*r,j+fy[k]*c),Id(i,j));
if(In(i+fx[k]*c,j+fy[k]*r)&&mp[i+fx[k]*c][j+fy[k]*r]!='@')
Insert(Id(i,j),Id(i+fx[k]*c,j+fy[k]*r)),
Insert(Id(i+fx[k]*c,j+fy[k]*r),Id(i,j));
}
int sx=0,sy=0,ex=0,ey=0;
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++){
if(mp[i][j]=='A') sx=i,sy=j;
if(mp[i][j]=='B') ex=i,ey=j;
}
dfs(Id(sx,sy));
if(tot==1) puts("Bob");
else if(!vis[Id(ex,ey)]) puts("Alice");
else {
if(Dep[Id(ex,ey)]) puts("Bob");
else puts("Alice");
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 13ms
memory: 24368kb
Test #2:
score: 0
Accepted
time: 1ms
memory: 9948kb
Test #3:
score: 0
Accepted
time: 86ms
memory: 46012kb
Test #4:
score: 0
Accepted
time: 45ms
memory: 27992kb
Test #5:
score: 0
Accepted
time: 2ms
memory: 11928kb
Test #6:
score: 0
Accepted
time: 3ms
memory: 15292kb
Test #7:
score: 0
Accepted
time: 3ms
memory: 9880kb
Test #8:
score: 0
Accepted
time: 4ms
memory: 9788kb
Test #9:
score: 0
Accepted
time: 21ms
memory: 23776kb
Test #10:
score: 0
Accepted
time: 14ms
memory: 16764kb
Test #11:
score: 0
Accepted
time: 5ms
memory: 12548kb
Test #12:
score: 0
Accepted
time: 23ms
memory: 34336kb
Test #13:
score: 0
Accepted
time: 18ms
memory: 22284kb
Test #14:
score: 0
Accepted
time: 14ms
memory: 21932kb
Test #15:
score: 0
Accepted
time: 3ms
memory: 10748kb
Test #16:
score: 0
Accepted
time: 17ms
memory: 13984kb
Test #17:
score: 0
Accepted
time: 3ms
memory: 12056kb
Test #18:
score: 0
Accepted
time: 3ms
memory: 16184kb
Test #19:
score: 0
Accepted
time: 3ms
memory: 14508kb
Test #20:
score: 0
Accepted
time: 4ms
memory: 18312kb
Test #21:
score: 0
Accepted
time: 4ms
memory: 9664kb
Test #22:
score: 0
Accepted
time: 2ms
memory: 10016kb
Test #23:
score: 0
Accepted
time: 0ms
memory: 9776kb
Test #24:
score: 0
Accepted
time: 11ms
memory: 11932kb
Test #25:
score: 0
Accepted
time: 2ms
memory: 14260kb
Test #26:
score: 0
Accepted
time: 2ms
memory: 9772kb
Test #27:
score: 0
Accepted
time: 3ms
memory: 11840kb
Test #28:
score: 0
Accepted
time: 138ms
memory: 49880kb
Test #29:
score: 0
Accepted
time: 4ms
memory: 12028kb
Test #30:
score: 0
Accepted
time: 14ms
memory: 16888kb
Test #31:
score: 0
Accepted
time: 11ms
memory: 14152kb
Test #32:
score: 0
Accepted
time: 4ms
memory: 9780kb
Test #33:
score: 0
Accepted
time: 63ms
memory: 37620kb
Test #34:
score: 0
Accepted
time: 5ms
memory: 12500kb
Test #35:
score: 0
Accepted
time: 63ms
memory: 37772kb
Test #36:
score: 0
Accepted
time: 39ms
memory: 36200kb
Test #37:
score: 0
Accepted
time: 9ms
memory: 14104kb
Test #38:
score: 0
Accepted
time: 22ms
memory: 19884kb
Test #39:
score: 0
Accepted
time: 3ms
memory: 12116kb
Test #40:
score: 0
Accepted
time: 7ms
memory: 11852kb
Test #41:
score: 0
Accepted
time: 8ms
memory: 14868kb
Test #42:
score: 0
Accepted
time: 5ms
memory: 13192kb
Test #43:
score: 0
Accepted
time: 13ms
memory: 20028kb
Test #44:
score: 0
Accepted
time: 6ms
memory: 9848kb
Test #45:
score: 0
Accepted
time: 4ms
memory: 10188kb
Test #46:
score: 0
Accepted
time: 3ms
memory: 12048kb
Test #47:
score: 0
Accepted
time: 4ms
memory: 11956kb
Test #48:
score: 0
Accepted
time: 32ms
memory: 35328kb
Test #49:
score: 0
Accepted
time: 15ms
memory: 23480kb
Test #50:
score: 0
Accepted
time: 5ms
memory: 13664kb
Test #51:
score: 0
Accepted
time: 265ms
memory: 60500kb
Test #52:
score: 0
Accepted
time: 89ms
memory: 71868kb
Test #53:
score: 0
Accepted
time: 3ms
memory: 20724kb
Test #54:
score: 0
Accepted
time: 291ms
memory: 112496kb
Test #55:
score: 0
Accepted
time: 53ms
memory: 39568kb
Test #56:
score: 0
Accepted
time: 429ms
memory: 92628kb
Test #57:
score: 0
Accepted
time: 119ms
memory: 37500kb
Test #58:
score: 0
Accepted
time: 9ms
memory: 16572kb
Test #59:
score: 0
Accepted
time: 19ms
memory: 22772kb
Test #60:
score: 0
Accepted
time: 501ms
memory: 101932kb
Test #61:
score: 0
Accepted
time: 36ms
memory: 32964kb
Test #62:
score: 0
Accepted
time: 29ms
memory: 28760kb
Test #63:
score: 0
Accepted
time: 253ms
memory: 62780kb
Test #64:
score: 0
Accepted
time: 15ms
memory: 22616kb
Test #65:
score: 0
Accepted
time: 72ms
memory: 108080kb
Test #66:
score: 0
Accepted
time: 16ms
memory: 20576kb
Test #67:
score: 0
Accepted
time: 64ms
memory: 45252kb
Test #68:
score: 0
Accepted
time: 31ms
memory: 20660kb
Test #69:
score: 0
Accepted
time: 492ms
memory: 114088kb
Test #70:
score: 0
Accepted
time: 58ms
memory: 31640kb
Test #71:
score: 0
Accepted
time: 25ms
memory: 30856kb
Test #72:
score: 0
Accepted
time: 4ms
memory: 20724kb
Test #73:
score: 0
Accepted
time: 16ms
memory: 26664kb
Test #74:
score: 0
Accepted
time: 425ms
memory: 93956kb
Test #75:
score: 0
Accepted
time: 31ms
memory: 38108kb
Test #76:
score: 0
Accepted
time: 35ms
memory: 44480kb
Test #77:
score: 0
Accepted
time: 342ms
memory: 74668kb
Test #78:
score: 0
Accepted
time: 11ms
memory: 22620kb
Test #79:
score: 0
Accepted
time: 25ms
memory: 24708kb
Test #80:
score: 0
Accepted
time: 129ms
memory: 42180kb
Test #81:
score: 0
Accepted
time: 23ms
memory: 35596kb
Test #82:
score: 0
Accepted
time: 39ms
memory: 36992kb
Test #83:
score: 0
Accepted
time: 21ms
memory: 32976kb
Test #84:
score: 0
Accepted
time: 23ms
memory: 24624kb
Test #85:
score: 0
Accepted
time: 14ms
memory: 22644kb
Test #86:
score: 0
Accepted
time: 15ms
memory: 20612kb
Test #87:
score: 0
Accepted
time: 18ms
memory: 22724kb
Test #88:
score: 0
Accepted
time: 16ms
memory: 16480kb
Test #89:
score: 0
Accepted
time: 440ms
memory: 92104kb
Test #90:
score: 0
Accepted
time: 38ms
memory: 36092kb
Test #91:
score: 0
Accepted
time: 9ms
memory: 20528kb
Test #92:
score: 0
Accepted
time: 149ms
memory: 101488kb
Test #93:
score: 0
Accepted
time: 13ms
memory: 22732kb
Test #94:
score: 0
Accepted
time: 390ms
memory: 80568kb
Test #95:
score: 0
Accepted
time: 49ms
memory: 96060kb
Test #96:
score: 0
Accepted
time: 40ms
memory: 39620kb
Test #97:
score: 0
Accepted
time: 329ms
memory: 93720kb
Test #98:
score: 0
Accepted
time: 218ms
memory: 61416kb
Test #99:
score: 0
Accepted
time: 46ms
memory: 61028kb
Test #100:
score: 0
Accepted
time: 48ms
memory: 74548kb
Test #101:
score: 0
Accepted
time: 90ms
memory: 117348kb
Test #102:
score: 0
Accepted
time: 48ms
memory: 107748kb
Test #103:
score: 0
Accepted
time: 407ms
memory: 87508kb
Test #104:
score: 0
Accepted
time: 36ms
memory: 28856kb
Test #105:
score: 0
Accepted
time: 42ms
memory: 65396kb
Test #106:
score: 0
Accepted
time: 29ms
memory: 34912kb
Test #107:
score: 0
Accepted
time: 318ms
memory: 77656kb
Test #108:
score: 0
Accepted
time: 460ms
memory: 97036kb
Test #109:
score: 0
Accepted
time: 183ms
memory: 50396kb
Test #110:
score: 0
Accepted
time: 237ms
memory: 88860kb
Test #111:
score: 0
Accepted
time: 122ms
memory: 52516kb
Test #112:
score: 0
Accepted
time: 68ms
memory: 85852kb
Test #113:
score: 0
Accepted
time: 23ms
memory: 16560kb
Test #114:
score: 0
Accepted
time: 5ms
memory: 16564kb
Test #115:
score: 0
Accepted
time: 14ms
memory: 22776kb
Test #116:
score: 0
Accepted
time: 71ms
memory: 94696kb
Test #117:
score: 0
Accepted
time: 103ms
memory: 115740kb
Test #118:
score: 0
Accepted
time: 14ms
memory: 18528kb
Test #119:
score: 0
Accepted
time: 10ms
memory: 11924kb
Test #120:
score: 0
Accepted
time: 218ms
memory: 63848kb
Test #121:
score: 0
Accepted
time: 19ms
memory: 20660kb
Test #122:
score: 0
Accepted
time: 13ms
memory: 32980kb
Test #123:
score: 0
Accepted
time: 13ms
memory: 20568kb
Test #124:
score: 0
Accepted
time: 11ms
memory: 24752kb
Test #125:
score: 0
Accepted
time: 65ms
memory: 37328kb
Test #126:
score: 0
Accepted
time: 15ms
memory: 22708kb
Test #127:
score: 0
Accepted
time: 23ms
memory: 16556kb
Test #128:
score: 0
Accepted
time: 22ms
memory: 34916kb
Test #129:
score: 0
Accepted
time: 12ms
memory: 22624kb
Test #130:
score: 0
Accepted
time: 63ms
memory: 64512kb
Test #131:
score: 0
Accepted
time: 9ms
memory: 20524kb
Test #132:
score: 0
Accepted
time: 182ms
memory: 51940kb
Test #133:
score: 0
Accepted
time: 13ms
memory: 14428kb
Test #134:
score: 0
Accepted
time: 27ms
memory: 28920kb
Test #135:
score: 0
Accepted
time: 488ms
memory: 101164kb
Test #136:
score: 0
Accepted
time: 13ms
memory: 16632kb
Test #137:
score: 0
Accepted
time: 10ms
memory: 22712kb
Test #138:
score: 0
Accepted
time: 473ms
memory: 103180kb
Test #139:
score: 0
Accepted
time: 4ms
memory: 20672kb
Test #140:
score: 0
Accepted
time: 13ms
memory: 32956kb
Test #141:
score: 0
Accepted
time: 128ms
memory: 81276kb
Test #142:
score: 0
Accepted
time: 20ms
memory: 22612kb
Test #143:
score: 0
Accepted
time: 502ms
memory: 115976kb
Test #144:
score: 0
Accepted
time: 54ms
memory: 47360kb
Test #145:
score: 0
Accepted
time: 132ms
memory: 50676kb
Test #146:
score: 0
Accepted
time: 20ms
memory: 31016kb
Test #147:
score: 0
Accepted
time: 153ms
memory: 117340kb
Test #148:
score: 0
Accepted
time: 307ms
memory: 79244kb
Test #149:
score: 0
Accepted
time: 77ms
memory: 46212kb
Test #150:
score: 0
Accepted
time: 307ms
memory: 81496kb
Test #151:
score: 0
Accepted
time: 517ms
memory: 137476kb
Test #152:
score: 0
Accepted
time: 19ms
memory: 20580kb
Test #153:
score: 0
Accepted
time: 11ms
memory: 18476kb
Test #154:
score: 0
Accepted
time: 16ms
memory: 22708kb
Test #155:
score: 0
Accepted
time: 293ms
memory: 75236kb
Test #156:
score: 0
Accepted
time: 24ms
memory: 26668kb
Test #157:
score: 0
Accepted
time: 16ms
memory: 30836kb
Test #158:
score: 0
Accepted
time: 30ms
memory: 34864kb
Test #159:
score: 0
Accepted
time: 15ms
memory: 16632kb
Test #160:
score: 0
Accepted
time: 7ms
memory: 22772kb
Test #161:
score: 0
Accepted
time: 71ms
memory: 34996kb
Test #162:
score: 0
Accepted
time: 10ms
memory: 18636kb
Test #163:
score: 0
Accepted
time: 12ms
memory: 11708kb
Test #164:
score: 0
Accepted
time: 104ms
memory: 49584kb
Test #165:
score: 0
Accepted
time: 240ms
memory: 97600kb
Test #166:
score: 0
Accepted
time: 273ms
memory: 71632kb