QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#17930 | #2213. Knight | CharlieVinnie# | AC ✓ | 417ms | 99396kb | C++14 | 1.4kb | 2022-01-15 12:45:24 | 2022-05-04 16:26:23 |
Judging History
answer
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Rev(i,a,b) for(int i=a;i>=b;i--)
#define clr(a,v) memset(a,v,sizeof(a))
#define Freopen(file) \
freopen(file".in","r",stdin); \
freopen(file".out","w",stdout);
//#define int long long
using namespace std;
const int N=1e3+5;
char mp[N][N];
int n,m,r,c;
int num[N][N],ncnt;
vector<int> to[N*N];
int col[N*N];
void add(int x,int y)
{
to[x].push_back(y);
}
void dfs(int u,int cc)
{
col[u]=cc;
for(auto v:to[u]){
if(col[v]){
assert(col[v]==3-cc);
continue;
}
dfs(v,3-cc);
}
}
bool valid(int x,int y)
{
return x>=1 && x<=n && y>=1 && y<=m && mp[x][y]!='@';
}
signed main()
{
cin>>n>>m>>r>>c;
For(i,1,n) cin>>(mp[i]+1);
if(r==0&&c==0){
puts("Bob");
return 0;
}
int S=0,T=0;
For(i,1,n){
For(j,1,m){
if(mp[i][j]!='@') num[i][j]=++ncnt;
if(mp[i][j]=='A') S=ncnt;
if(mp[i][j]=='B') T=ncnt;
}
}
For(i,1,n){
For(j,1,m){
if(mp[i][j]!='@'){
for(int x=-1;x<=1;x+=2){
for(int y=-1;y<=1;y+=2){
if(valid(i+x*r,j+y*c)) add(num[i][j],num[i+x*r][j+y*c]);
if(valid(i+x*c,j+y*r)) add(num[i][j],num[i+x*c][j+y*r]);
}
}
}
}
}
if(to[S].empty()){
puts("Bob");
return 0;
}
dfs(S,1);
if(col[T]==0){
puts("Alice");
}
else{
if(col[T]==col[S]){
puts("Alice");
}
else{
puts("Bob");
}
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 47ms
memory: 45404kb
Test #2:
score: 0
Accepted
time: 12ms
memory: 29976kb
Test #3:
score: 0
Accepted
time: 145ms
memory: 53268kb
Test #4:
score: 0
Accepted
time: 76ms
memory: 41496kb
Test #5:
score: 0
Accepted
time: 8ms
memory: 28300kb
Test #6:
score: 0
Accepted
time: 18ms
memory: 34024kb
Test #7:
score: 0
Accepted
time: 5ms
memory: 29032kb
Test #8:
score: 0
Accepted
time: 16ms
memory: 29548kb
Test #9:
score: 0
Accepted
time: 31ms
memory: 41252kb
Test #10:
score: 0
Accepted
time: 22ms
memory: 32428kb
Test #11:
score: 0
Accepted
time: 8ms
memory: 32788kb
Test #12:
score: 0
Accepted
time: 71ms
memory: 50544kb
Test #13:
score: 0
Accepted
time: 26ms
memory: 34748kb
Test #14:
score: 0
Accepted
time: 42ms
memory: 44240kb
Test #15:
score: 0
Accepted
time: 10ms
memory: 32636kb
Test #16:
score: 0
Accepted
time: 24ms
memory: 33312kb
Test #17:
score: 0
Accepted
time: 10ms
memory: 29004kb
Test #18:
score: 0
Accepted
time: 17ms
memory: 33492kb
Test #19:
score: 0
Accepted
time: 7ms
memory: 29772kb
Test #20:
score: 0
Accepted
time: 38ms
memory: 41224kb
Test #21:
score: 0
Accepted
time: 3ms
memory: 27460kb
Test #22:
score: 0
Accepted
time: 11ms
memory: 29608kb
Test #23:
score: 0
Accepted
time: 2ms
memory: 27880kb
Test #24:
score: 0
Accepted
time: 21ms
memory: 31836kb
Test #25:
score: 0
Accepted
time: 17ms
memory: 34452kb
Test #26:
score: 0
Accepted
time: 11ms
memory: 29592kb
Test #27:
score: 0
Accepted
time: 3ms
memory: 28444kb
Test #28:
score: 0
Accepted
time: 134ms
memory: 53264kb
Test #29:
score: 0
Accepted
time: 16ms
memory: 30716kb
Test #30:
score: 0
Accepted
time: 19ms
memory: 33408kb
Test #31:
score: 0
Accepted
time: 18ms
memory: 32556kb
Test #32:
score: 0
Accepted
time: 4ms
memory: 27892kb
Test #33:
score: 0
Accepted
time: 102ms
memory: 49016kb
Test #34:
score: 0
Accepted
time: 13ms
memory: 32432kb
Test #35:
score: 0
Accepted
time: 65ms
memory: 46136kb
Test #36:
score: 0
Accepted
time: 90ms
memory: 51192kb
Test #37:
score: 0
Accepted
time: 11ms
memory: 31288kb
Test #38:
score: 0
Accepted
time: 33ms
memory: 32912kb
Test #39:
score: 0
Accepted
time: 7ms
memory: 29592kb
Test #40:
score: 0
Accepted
time: 8ms
memory: 31788kb
Test #41:
score: 0
Accepted
time: 21ms
memory: 34380kb
Test #42:
score: 0
Accepted
time: 16ms
memory: 32620kb
Test #43:
score: 0
Accepted
time: 28ms
memory: 36732kb
Test #44:
score: 0
Accepted
time: 10ms
memory: 30252kb
Test #45:
score: 0
Accepted
time: 5ms
memory: 30780kb
Test #46:
score: 0
Accepted
time: 12ms
memory: 31160kb
Test #47:
score: 0
Accepted
time: 4ms
memory: 30608kb
Test #48:
score: 0
Accepted
time: 81ms
memory: 47424kb
Test #49:
score: 0
Accepted
time: 42ms
memory: 40860kb
Test #50:
score: 0
Accepted
time: 19ms
memory: 33576kb
Test #51:
score: 0
Accepted
time: 257ms
memory: 66468kb
Test #52:
score: 0
Accepted
time: 192ms
memory: 66380kb
Test #53:
score: 0
Accepted
time: 41ms
memory: 39092kb
Test #54:
score: 0
Accepted
time: 279ms
memory: 85600kb
Test #55:
score: 0
Accepted
time: 119ms
memory: 51536kb
Test #56:
score: 0
Accepted
time: 387ms
memory: 83240kb
Test #57:
score: 0
Accepted
time: 136ms
memory: 50892kb
Test #58:
score: 0
Accepted
time: 47ms
memory: 36948kb
Test #59:
score: 0
Accepted
time: 45ms
memory: 38244kb
Test #60:
score: 0
Accepted
time: 375ms
memory: 86816kb
Test #61:
score: 0
Accepted
time: 87ms
memory: 47308kb
Test #62:
score: 0
Accepted
time: 75ms
memory: 44308kb
Test #63:
score: 0
Accepted
time: 292ms
memory: 69140kb
Test #64:
score: 0
Accepted
time: 53ms
memory: 38272kb
Test #65:
score: 0
Accepted
time: 174ms
memory: 77864kb
Test #66:
score: 0
Accepted
time: 54ms
memory: 37748kb
Test #67:
score: 0
Accepted
time: 148ms
memory: 56092kb
Test #68:
score: 0
Accepted
time: 57ms
memory: 40580kb
Test #69:
score: 0
Accepted
time: 348ms
memory: 90356kb
Test #70:
score: 0
Accepted
time: 94ms
memory: 44924kb
Test #71:
score: 0
Accepted
time: 55ms
memory: 46248kb
Test #72:
score: 0
Accepted
time: 35ms
memory: 37060kb
Test #73:
score: 0
Accepted
time: 75ms
memory: 52072kb
Test #74:
score: 0
Accepted
time: 367ms
memory: 83848kb
Test #75:
score: 0
Accepted
time: 107ms
memory: 54256kb
Test #76:
score: 0
Accepted
time: 116ms
memory: 55400kb
Test #77:
score: 0
Accepted
time: 325ms
memory: 74824kb
Test #78:
score: 0
Accepted
time: 41ms
memory: 36568kb
Test #79:
score: 0
Accepted
time: 62ms
memory: 41492kb
Test #80:
score: 0
Accepted
time: 185ms
memory: 56468kb
Test #81:
score: 0
Accepted
time: 100ms
memory: 53420kb
Test #82:
score: 0
Accepted
time: 109ms
memory: 50184kb
Test #83:
score: 0
Accepted
time: 96ms
memory: 48796kb
Test #84:
score: 0
Accepted
time: 65ms
memory: 42292kb
Test #85:
score: 0
Accepted
time: 40ms
memory: 37684kb
Test #86:
score: 0
Accepted
time: 44ms
memory: 37848kb
Test #87:
score: 0
Accepted
time: 44ms
memory: 41976kb
Test #88:
score: 0
Accepted
time: 43ms
memory: 37800kb
Test #89:
score: 0
Accepted
time: 404ms
memory: 83584kb
Test #90:
score: 0
Accepted
time: 82ms
memory: 50604kb
Test #91:
score: 0
Accepted
time: 32ms
memory: 36216kb
Test #92:
score: 0
Accepted
time: 200ms
memory: 77024kb
Test #93:
score: 0
Accepted
time: 44ms
memory: 39664kb
Test #94:
score: 0
Accepted
time: 323ms
memory: 77348kb
Test #95:
score: 0
Accepted
time: 185ms
memory: 70600kb
Test #96:
score: 0
Accepted
time: 110ms
memory: 55104kb
Test #97:
score: 0
Accepted
time: 272ms
memory: 82004kb
Test #98:
score: 0
Accepted
time: 284ms
memory: 71820kb
Test #99:
score: 0
Accepted
time: 146ms
memory: 65852kb
Test #100:
score: 0
Accepted
time: 140ms
memory: 66648kb
Test #101:
score: 0
Accepted
time: 185ms
memory: 79372kb
Test #102:
score: 0
Accepted
time: 165ms
memory: 75020kb
Test #103:
score: 0
Accepted
time: 331ms
memory: 78668kb
Test #104:
score: 0
Accepted
time: 87ms
memory: 45276kb
Test #105:
score: 0
Accepted
time: 128ms
memory: 63056kb
Test #106:
score: 0
Accepted
time: 86ms
memory: 53304kb
Test #107:
score: 0
Accepted
time: 305ms
memory: 75596kb
Test #108:
score: 0
Accepted
time: 365ms
memory: 85676kb
Test #109:
score: 0
Accepted
time: 210ms
memory: 60436kb
Test #110:
score: 0
Accepted
time: 270ms
memory: 76788kb
Test #111:
score: 0
Accepted
time: 187ms
memory: 60012kb
Test #112:
score: 0
Accepted
time: 173ms
memory: 72292kb
Test #113:
score: 0
Accepted
time: 37ms
memory: 37924kb
Test #114:
score: 0
Accepted
time: 41ms
memory: 36664kb
Test #115:
score: 0
Accepted
time: 44ms
memory: 40104kb
Test #116:
score: 0
Accepted
time: 147ms
memory: 72420kb
Test #117:
score: 0
Accepted
time: 180ms
memory: 81176kb
Test #118:
score: 0
Accepted
time: 37ms
memory: 35456kb
Test #119:
score: 0
Accepted
time: 30ms
memory: 35404kb
Test #120:
score: 0
Accepted
time: 236ms
memory: 67424kb
Test #121:
score: 0
Accepted
time: 31ms
memory: 38960kb
Test #122:
score: 0
Accepted
time: 80ms
memory: 51604kb
Test #123:
score: 0
Accepted
time: 46ms
memory: 38580kb
Test #124:
score: 0
Accepted
time: 64ms
memory: 41224kb
Test #125:
score: 0
Accepted
time: 147ms
memory: 50572kb
Test #126:
score: 0
Accepted
time: 46ms
memory: 36604kb
Test #127:
score: 0
Accepted
time: 39ms
memory: 34656kb
Test #128:
score: 0
Accepted
time: 83ms
memory: 57072kb
Test #129:
score: 0
Accepted
time: 42ms
memory: 41492kb
Test #130:
score: 0
Accepted
time: 140ms
memory: 63132kb
Test #131:
score: 0
Accepted
time: 31ms
memory: 36672kb
Test #132:
score: 0
Accepted
time: 208ms
memory: 60568kb
Test #133:
score: 0
Accepted
time: 37ms
memory: 38568kb
Test #134:
score: 0
Accepted
time: 71ms
memory: 46588kb
Test #135:
score: 0
Accepted
time: 381ms
memory: 86376kb
Test #136:
score: 0
Accepted
time: 38ms
memory: 36220kb
Test #137:
score: 0
Accepted
time: 74ms
memory: 39412kb
Test #138:
score: 0
Accepted
time: 372ms
memory: 88764kb
Test #139:
score: 0
Accepted
time: 39ms
memory: 36708kb
Test #140:
score: 0
Accepted
time: 69ms
memory: 50444kb
Test #141:
score: 0
Accepted
time: 195ms
memory: 72436kb
Test #142:
score: 0
Accepted
time: 54ms
memory: 42316kb
Test #143:
score: 0
Accepted
time: 417ms
memory: 90876kb
Test #144:
score: 0
Accepted
time: 105ms
memory: 54888kb
Test #145:
score: 0
Accepted
time: 284ms
memory: 67748kb
Test #146:
score: 0
Accepted
time: 66ms
memory: 45284kb
Test #147:
score: 0
Accepted
time: 243ms
memory: 83740kb
Test #148:
score: 0
Accepted
time: 325ms
memory: 76824kb
Test #149:
score: 0
Accepted
time: 189ms
memory: 63072kb
Test #150:
score: 0
Accepted
time: 374ms
memory: 77960kb
Test #151:
score: 0
Accepted
time: 405ms
memory: 99396kb
Test #152:
score: 0
Accepted
time: 35ms
memory: 37124kb
Test #153:
score: 0
Accepted
time: 38ms
memory: 36896kb
Test #154:
score: 0
Accepted
time: 69ms
memory: 42320kb
Test #155:
score: 0
Accepted
time: 356ms
memory: 73200kb
Test #156:
score: 0
Accepted
time: 67ms
memory: 45024kb
Test #157:
score: 0
Accepted
time: 74ms
memory: 52668kb
Test #158:
score: 0
Accepted
time: 97ms
memory: 50464kb
Test #159:
score: 0
Accepted
time: 33ms
memory: 35140kb
Test #160:
score: 0
Accepted
time: 53ms
memory: 38120kb
Test #161:
score: 0
Accepted
time: 122ms
memory: 47752kb
Test #162:
score: 0
Accepted
time: 55ms
memory: 39456kb
Test #163:
score: 0
Accepted
time: 17ms
memory: 34500kb
Test #164:
score: 0
Accepted
time: 167ms
memory: 58448kb
Test #165:
score: 0
Accepted
time: 264ms
memory: 80520kb
Test #166:
score: 0
Accepted
time: 298ms
memory: 71336kb