QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#17921 | #2213. Knight | qingyu_orz | AC ✓ | 793ms | 130820kb | C++14 | 1.3kb | 2022-01-15 12:18:46 | 2022-05-04 16:20:36 |
Judging History
answer
#include<bits/stdc++.h>
#define mk(x,y) ((x-1)*m+y)
using namespace std;
char s[1005][1005];
vector<int>g[1000005];
int mb[8][2];
int col[1000005];
void dfs(int x){
for(auto cu:g[x]){
if(col[cu]){
assert(col[x]+col[cu]==0);
continue;
}
col[cu]=-col[x];
dfs(cu);
}
}
int main(){
int n,m,x,y;
cin>>n>>m>>x>>y;
for(int i=1;i<=n;++i)scanf("%s",s[i]+1);
mb[0][0]=x,mb[0][1]=y;
mb[1][0]=-x,mb[1][1]=y;
mb[2][0]=x,mb[2][1]=-y;
mb[3][0]=-x,mb[3][1]=-y;
mb[4][0]=y,mb[4][1]=x;
mb[5][0]=-y,mb[5][1]=x;
mb[6][0]=y,mb[6][1]=-x;
mb[7][0]=-y,mb[7][1]=-x;
for(int i=1;i<=n;++i)for(int j=1;j<=m;++j)
if(s[i][j]!='@'){
for(int k=0;k<8;++k){
int dx=i+mb[k][0],dy=j+mb[k][1];
if(dx<1||dy<1||dx>n||dy>m)continue;
if(s[dx][dy]=='@')continue;
int u=mk(i,j),v=mk(dx,dy);
g[u].emplace_back(v);
g[v].emplace_back(u);
}
}
int A=-1,B=-1;
for(int i=1;i<=n;++i)for(int j=1;j<=m;++j){
if(s[i][j]=='A')A=mk(i,j);
else if(s[i][j]=='B')B=mk(i,j);
}
if(!g[A].size()){
puts("Bob");
return 0;
}
int N=mk(n,m);
for(int i=1;i<=N;++i)if(!col[i]){
col[i]=i;
dfs(i);
}
if(abs(col[A])!=abs(col[B]))puts("Alice");
else if(col[A]==col[B])puts("Alice");
else puts("Bob");
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 52ms
memory: 44160kb
Test #2:
score: 0
Accepted
time: 0ms
memory: 28688kb
Test #3:
score: 0
Accepted
time: 305ms
memory: 61276kb
Test #4:
score: 0
Accepted
time: 138ms
memory: 42452kb
Test #5:
score: 0
Accepted
time: 2ms
memory: 28476kb
Test #6:
score: 0
Accepted
time: 8ms
memory: 31488kb
Test #7:
score: 0
Accepted
time: 6ms
memory: 28484kb
Test #8:
score: 0
Accepted
time: 6ms
memory: 28448kb
Test #9:
score: 0
Accepted
time: 56ms
memory: 37320kb
Test #10:
score: 0
Accepted
time: 23ms
memory: 32740kb
Test #11:
score: 0
Accepted
time: 8ms
memory: 29264kb
Test #12:
score: 0
Accepted
time: 148ms
memory: 51088kb
Test #13:
score: 0
Accepted
time: 32ms
memory: 37328kb
Test #14:
score: 0
Accepted
time: 58ms
memory: 42724kb
Test #15:
score: 0
Accepted
time: 12ms
memory: 30764kb
Test #16:
score: 0
Accepted
time: 13ms
memory: 29412kb
Test #17:
score: 0
Accepted
time: 5ms
memory: 28440kb
Test #18:
score: 0
Accepted
time: 25ms
memory: 32164kb
Test #19:
score: 0
Accepted
time: 11ms
memory: 29420kb
Test #20:
score: 0
Accepted
time: 25ms
memory: 38432kb
Test #21:
score: 0
Accepted
time: 5ms
memory: 29064kb
Test #22:
score: 0
Accepted
time: 10ms
memory: 29632kb
Test #23:
score: 0
Accepted
time: 4ms
memory: 28236kb
Test #24:
score: 0
Accepted
time: 9ms
memory: 28364kb
Test #25:
score: 0
Accepted
time: 6ms
memory: 32580kb
Test #26:
score: 0
Accepted
time: 8ms
memory: 29156kb
Test #27:
score: 0
Accepted
time: 5ms
memory: 28668kb
Test #28:
score: 0
Accepted
time: 216ms
memory: 63896kb
Test #29:
score: 0
Accepted
time: 5ms
memory: 29524kb
Test #30:
score: 0
Accepted
time: 16ms
memory: 33364kb
Test #31:
score: 0
Accepted
time: 20ms
memory: 31940kb
Test #32:
score: 0
Accepted
time: 4ms
memory: 28220kb
Test #33:
score: 0
Accepted
time: 212ms
memory: 55644kb
Test #34:
score: 0
Accepted
time: 11ms
memory: 31036kb
Test #35:
score: 0
Accepted
time: 204ms
memory: 54580kb
Test #36:
score: 0
Accepted
time: 281ms
memory: 55008kb
Test #37:
score: 0
Accepted
time: 8ms
memory: 32472kb
Test #38:
score: 0
Accepted
time: 38ms
memory: 34368kb
Test #39:
score: 0
Accepted
time: 5ms
memory: 31612kb
Test #40:
score: 0
Accepted
time: 3ms
memory: 28416kb
Test #41:
score: 0
Accepted
time: 21ms
memory: 31948kb
Test #42:
score: 0
Accepted
time: 14ms
memory: 31460kb
Test #43:
score: 0
Accepted
time: 27ms
memory: 35700kb
Test #44:
score: 0
Accepted
time: 2ms
memory: 29140kb
Test #45:
score: 0
Accepted
time: 5ms
memory: 29404kb
Test #46:
score: 0
Accepted
time: 4ms
memory: 29080kb
Test #47:
score: 0
Accepted
time: 8ms
memory: 29972kb
Test #48:
score: 0
Accepted
time: 214ms
memory: 49540kb
Test #49:
score: 0
Accepted
time: 44ms
memory: 40348kb
Test #50:
score: 0
Accepted
time: 18ms
memory: 35776kb
Test #51:
score: 0
Accepted
time: 493ms
memory: 76812kb
Test #52:
score: 0
Accepted
time: 491ms
memory: 80448kb
Test #53:
score: 0
Accepted
time: 86ms
memory: 37708kb
Test #54:
score: 0
Accepted
time: 659ms
memory: 112004kb
Test #55:
score: 0
Accepted
time: 293ms
memory: 54304kb
Test #56:
score: 0
Accepted
time: 657ms
memory: 104724kb
Test #57:
score: 0
Accepted
time: 244ms
memory: 53380kb
Test #58:
score: 0
Accepted
time: 25ms
memory: 31672kb
Test #59:
score: 0
Accepted
time: 63ms
memory: 37408kb
Test #60:
score: 0
Accepted
time: 709ms
memory: 109016kb
Test #61:
score: 0
Accepted
time: 230ms
memory: 50784kb
Test #62:
score: 0
Accepted
time: 172ms
memory: 43532kb
Test #63:
score: 0
Accepted
time: 487ms
memory: 80824kb
Test #64:
score: 0
Accepted
time: 78ms
memory: 37584kb
Test #65:
score: 0
Accepted
time: 758ms
memory: 106068kb
Test #66:
score: 0
Accepted
time: 87ms
memory: 37232kb
Test #67:
score: 0
Accepted
time: 381ms
memory: 61520kb
Test #68:
score: 0
Accepted
time: 55ms
memory: 36692kb
Test #69:
score: 0
Accepted
time: 749ms
memory: 114164kb
Test #70:
score: 0
Accepted
time: 200ms
memory: 46048kb
Test #71:
score: 0
Accepted
time: 206ms
memory: 46480kb
Test #72:
score: 0
Accepted
time: 67ms
memory: 35800kb
Test #73:
score: 0
Accepted
time: 73ms
memory: 47684kb
Test #74:
score: 0
Accepted
time: 652ms
memory: 106584kb
Test #75:
score: 0
Accepted
time: 292ms
memory: 58872kb
Test #76:
score: 0
Accepted
time: 397ms
memory: 63280kb
Test #77:
score: 0
Accepted
time: 579ms
memory: 92268kb
Test #78:
score: 0
Accepted
time: 48ms
memory: 35696kb
Test #79:
score: 0
Accepted
time: 109ms
memory: 40380kb
Test #80:
score: 0
Accepted
time: 364ms
memory: 60012kb
Test #81:
score: 0
Accepted
time: 257ms
memory: 57604kb
Test #82:
score: 0
Accepted
time: 302ms
memory: 55252kb
Test #83:
score: 0
Accepted
time: 97ms
memory: 49988kb
Test #84:
score: 0
Accepted
time: 155ms
memory: 42212kb
Test #85:
score: 0
Accepted
time: 90ms
memory: 36620kb
Test #86:
score: 0
Accepted
time: 68ms
memory: 36740kb
Test #87:
score: 0
Accepted
time: 95ms
memory: 40664kb
Test #88:
score: 0
Accepted
time: 83ms
memory: 36824kb
Test #89:
score: 0
Accepted
time: 672ms
memory: 106636kb
Test #90:
score: 0
Accepted
time: 308ms
memory: 55896kb
Test #91:
score: 0
Accepted
time: 77ms
memory: 35992kb
Test #92:
score: 0
Accepted
time: 683ms
memory: 97704kb
Test #93:
score: 0
Accepted
time: 50ms
memory: 36364kb
Test #94:
score: 0
Accepted
time: 625ms
memory: 95324kb
Test #95:
score: 0
Accepted
time: 529ms
memory: 94948kb
Test #96:
score: 0
Accepted
time: 344ms
memory: 61316kb
Test #97:
score: 0
Accepted
time: 572ms
memory: 101376kb
Test #98:
score: 0
Accepted
time: 469ms
memory: 82112kb
Test #99:
score: 0
Accepted
time: 494ms
memory: 78824kb
Test #100:
score: 0
Accepted
time: 541ms
memory: 89924kb
Test #101:
score: 0
Accepted
time: 755ms
memory: 104668kb
Test #102:
score: 0
Accepted
time: 615ms
memory: 101200kb
Test #103:
score: 0
Accepted
time: 703ms
memory: 96004kb
Test #104:
score: 0
Accepted
time: 194ms
memory: 44188kb
Test #105:
score: 0
Accepted
time: 475ms
memory: 77564kb
Test #106:
score: 0
Accepted
time: 174ms
memory: 53636kb
Test #107:
score: 0
Accepted
time: 530ms
memory: 90756kb
Test #108:
score: 0
Accepted
time: 653ms
memory: 108676kb
Test #109:
score: 0
Accepted
time: 380ms
memory: 66412kb
Test #110:
score: 0
Accepted
time: 692ms
memory: 98360kb
Test #111:
score: 0
Accepted
time: 417ms
memory: 68240kb
Test #112:
score: 0
Accepted
time: 650ms
memory: 92492kb
Test #113:
score: 0
Accepted
time: 43ms
memory: 33324kb
Test #114:
score: 0
Accepted
time: 48ms
memory: 32940kb
Test #115:
score: 0
Accepted
time: 65ms
memory: 38064kb
Test #116:
score: 0
Accepted
time: 593ms
memory: 93376kb
Test #117:
score: 0
Accepted
time: 793ms
memory: 107960kb
Test #118:
score: 0
Accepted
time: 33ms
memory: 34116kb
Test #119:
score: 0
Accepted
time: 18ms
memory: 31576kb
Test #120:
score: 0
Accepted
time: 437ms
memory: 78088kb
Test #121:
score: 0
Accepted
time: 58ms
memory: 37824kb
Test #122:
score: 0
Accepted
time: 100ms
memory: 50660kb
Test #123:
score: 0
Accepted
time: 72ms
memory: 35468kb
Test #124:
score: 0
Accepted
time: 92ms
memory: 39544kb
Test #125:
score: 0
Accepted
time: 283ms
memory: 51856kb
Test #126:
score: 0
Accepted
time: 66ms
memory: 36424kb
Test #127:
score: 0
Accepted
time: 22ms
memory: 30500kb
Test #128:
score: 0
Accepted
time: 167ms
memory: 56592kb
Test #129:
score: 0
Accepted
time: 69ms
memory: 39508kb
Test #130:
score: 0
Accepted
time: 540ms
memory: 75708kb
Test #131:
score: 0
Accepted
time: 75ms
memory: 36004kb
Test #132:
score: 0
Accepted
time: 340ms
memory: 67676kb
Test #133:
score: 0
Accepted
time: 58ms
memory: 32648kb
Test #134:
score: 0
Accepted
time: 174ms
memory: 46500kb
Test #135:
score: 0
Accepted
time: 736ms
memory: 108832kb
Test #136:
score: 0
Accepted
time: 24ms
memory: 30944kb
Test #137:
score: 0
Accepted
time: 79ms
memory: 38252kb
Test #138:
score: 0
Accepted
time: 669ms
memory: 115180kb
Test #139:
score: 0
Accepted
time: 45ms
memory: 35132kb
Test #140:
score: 0
Accepted
time: 149ms
memory: 49096kb
Test #141:
score: 0
Accepted
time: 637ms
memory: 91284kb
Test #142:
score: 0
Accepted
time: 82ms
memory: 38532kb
Test #143:
score: 0
Accepted
time: 742ms
memory: 115028kb
Test #144:
score: 0
Accepted
time: 338ms
memory: 59672kb
Test #145:
score: 0
Accepted
time: 360ms
memory: 74044kb
Test #146:
score: 0
Accepted
time: 192ms
memory: 45300kb
Test #147:
score: 0
Accepted
time: 738ms
memory: 111068kb
Test #148:
score: 0
Accepted
time: 592ms
memory: 92536kb
Test #149:
score: 0
Accepted
time: 360ms
memory: 66576kb
Test #150:
score: 0
Accepted
time: 556ms
memory: 97972kb
Test #151:
score: 0
Accepted
time: 681ms
memory: 130820kb
Test #152:
score: 0
Accepted
time: 71ms
memory: 36400kb
Test #153:
score: 0
Accepted
time: 40ms
memory: 34408kb
Test #154:
score: 0
Accepted
time: 86ms
memory: 38176kb
Test #155:
score: 0
Accepted
time: 599ms
memory: 88548kb
Test #156:
score: 0
Accepted
time: 120ms
memory: 44672kb
Test #157:
score: 0
Accepted
time: 85ms
memory: 51116kb
Test #158:
score: 0
Accepted
time: 240ms
memory: 52960kb
Test #159:
score: 0
Accepted
time: 31ms
memory: 31544kb
Test #160:
score: 0
Accepted
time: 78ms
memory: 37096kb
Test #161:
score: 0
Accepted
time: 214ms
memory: 48552kb
Test #162:
score: 0
Accepted
time: 67ms
memory: 38828kb
Test #163:
score: 0
Accepted
time: 23ms
memory: 29824kb
Test #164:
score: 0
Accepted
time: 379ms
memory: 65112kb
Test #165:
score: 0
Accepted
time: 789ms
memory: 103660kb
Test #166:
score: 0
Accepted
time: 542ms
memory: 84760kb