QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#18003 | #2213. Knight | KJGKMTZB# | AC ✓ | 374ms | 102180kb | C++11 | 1.3kb | 2022-01-15 17:39:36 | 2022-05-04 16:38:38 |
Judging History
answer
#include <bits/stdc++.h>
#define rep(a,b,c) for(int a=(b);a<=(c);a++)
#define per(a,b,c) for(int a=(b);a>=(c);a--)
#define ll long long
#define vi vector<int>
#define pb emplace_back
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
const int N=1e6+5;
vi e[N];
int n,m,r,c,s,t,mp[1005][1005],mx[2]={1,-1},my[2]={1,-1},col[N];
char S[1005];
inline int id_(int i,int j) { return m*(i-1)+j; }
inline void dfs(int x) { for(int v:e[x]) if(!col[v]) col[v]=col[x]^3,dfs(v); }
inline void solve() {
scanf("%d %d %d %d",&n,&m,&r,&c);
rep(i,1,n) {
scanf("%s",S+1);
rep(j,1,m) {
if(S[j]=='A') s=id_(i,j);
if(S[j]=='B') t=id_(i,j);
if(S[j]=='@') mp[i][j]=0;
else mp[i][j]=1;
}
}
rep(i,1,n) rep(j,1,m) if(mp[i][j]) {
rep(m1,0,1) rep(m2,0,1) {
int tx=i+mx[m1]*r,ty=j+my[m2]*c;
if(tx>0&&ty>0&&tx<=n&&ty<=m&&mp[tx][ty]) e[id_(i,j)].pb(id_(tx,ty));
}
rep(m1,0,1) rep(m2,0,1) {
int tx=i+mx[m1]*c,ty=j+my[m2]*r;
if(tx>0&&ty>0&&tx<=n&&ty<=m&&mp[tx][ty]) e[id_(i,j)].pb(id_(tx,ty));
}
}
if(!r&&!c) return(void)(puts("Bob"));
if(e[s].empty()||(e[s].size()==1&&e[s][0]==t)) return(void)(puts("Bob"));
col[s]=1; dfs(s);
if(!col[t]) puts("Alice");
else if(col[t]==col[s]) puts("Alice");
else puts("Bob");
}
int main() {
//int T; cin>>T; while(T--)
solve();
}
詳細信息
Test #1:
score: 100
Accepted
time: 33ms
memory: 45908kb
Test #2:
score: 0
Accepted
time: 7ms
memory: 29968kb
Test #3:
score: 0
Accepted
time: 121ms
memory: 52248kb
Test #4:
score: 0
Accepted
time: 63ms
memory: 42124kb
Test #5:
score: 0
Accepted
time: 4ms
memory: 31048kb
Test #6:
score: 0
Accepted
time: 9ms
memory: 34968kb
Test #7:
score: 0
Accepted
time: 7ms
memory: 30776kb
Test #8:
score: 0
Accepted
time: 10ms
memory: 31932kb
Test #9:
score: 0
Accepted
time: 26ms
memory: 41472kb
Test #10:
score: 0
Accepted
time: 11ms
memory: 32396kb
Test #11:
score: 0
Accepted
time: 11ms
memory: 32724kb
Test #12:
score: 0
Accepted
time: 53ms
memory: 49408kb
Test #13:
score: 0
Accepted
time: 23ms
memory: 35860kb
Test #14:
score: 0
Accepted
time: 27ms
memory: 43456kb
Test #15:
score: 0
Accepted
time: 8ms
memory: 33204kb
Test #16:
score: 0
Accepted
time: 7ms
memory: 32244kb
Test #17:
score: 0
Accepted
time: 0ms
memory: 29412kb
Test #18:
score: 0
Accepted
time: 13ms
memory: 32588kb
Test #19:
score: 0
Accepted
time: 5ms
memory: 31812kb
Test #20:
score: 0
Accepted
time: 25ms
memory: 41728kb
Test #21:
score: 0
Accepted
time: 4ms
memory: 29364kb
Test #22:
score: 0
Accepted
time: 8ms
memory: 31396kb
Test #23:
score: 0
Accepted
time: 0ms
memory: 29852kb
Test #24:
score: 0
Accepted
time: 7ms
memory: 31972kb
Test #25:
score: 0
Accepted
time: 9ms
memory: 32476kb
Test #26:
score: 0
Accepted
time: 4ms
memory: 30704kb
Test #27:
score: 0
Accepted
time: 4ms
memory: 29828kb
Test #28:
score: 0
Accepted
time: 119ms
memory: 56152kb
Test #29:
score: 0
Accepted
time: 4ms
memory: 32628kb
Test #30:
score: 0
Accepted
time: 9ms
memory: 35624kb
Test #31:
score: 0
Accepted
time: 15ms
memory: 35516kb
Test #32:
score: 0
Accepted
time: 8ms
memory: 30360kb
Test #33:
score: 0
Accepted
time: 79ms
memory: 50516kb
Test #34:
score: 0
Accepted
time: 8ms
memory: 34076kb
Test #35:
score: 0
Accepted
time: 78ms
memory: 49604kb
Test #36:
score: 0
Accepted
time: 82ms
memory: 50636kb
Test #37:
score: 0
Accepted
time: 4ms
memory: 33732kb
Test #38:
score: 0
Accepted
time: 36ms
memory: 37200kb
Test #39:
score: 0
Accepted
time: 4ms
memory: 33056kb
Test #40:
score: 0
Accepted
time: 4ms
memory: 32968kb
Test #41:
score: 0
Accepted
time: 12ms
memory: 35380kb
Test #42:
score: 0
Accepted
time: 12ms
memory: 35084kb
Test #43:
score: 0
Accepted
time: 30ms
memory: 37564kb
Test #44:
score: 0
Accepted
time: 4ms
memory: 32056kb
Test #45:
score: 0
Accepted
time: 9ms
memory: 32396kb
Test #46:
score: 0
Accepted
time: 5ms
memory: 32232kb
Test #47:
score: 0
Accepted
time: 4ms
memory: 33368kb
Test #48:
score: 0
Accepted
time: 85ms
memory: 47604kb
Test #49:
score: 0
Accepted
time: 26ms
memory: 41756kb
Test #50:
score: 0
Accepted
time: 16ms
memory: 36740kb
Test #51:
score: 0
Accepted
time: 231ms
memory: 65936kb
Test #52:
score: 0
Accepted
time: 180ms
memory: 66156kb
Test #53:
score: 0
Accepted
time: 37ms
memory: 39280kb
Test #54:
score: 0
Accepted
time: 236ms
memory: 85904kb
Test #55:
score: 0
Accepted
time: 107ms
memory: 51392kb
Test #56:
score: 0
Accepted
time: 374ms
memory: 84568kb
Test #57:
score: 0
Accepted
time: 128ms
memory: 50924kb
Test #58:
score: 0
Accepted
time: 25ms
memory: 35748kb
Test #59:
score: 0
Accepted
time: 23ms
memory: 37812kb
Test #60:
score: 0
Accepted
time: 341ms
memory: 86620kb
Test #61:
score: 0
Accepted
time: 70ms
memory: 48160kb
Test #62:
score: 0
Accepted
time: 53ms
memory: 42952kb
Test #63:
score: 0
Accepted
time: 232ms
memory: 67516kb
Test #64:
score: 0
Accepted
time: 34ms
memory: 37536kb
Test #65:
score: 0
Accepted
time: 168ms
memory: 78308kb
Test #66:
score: 0
Accepted
time: 35ms
memory: 37504kb
Test #67:
score: 0
Accepted
time: 114ms
memory: 55448kb
Test #68:
score: 0
Accepted
time: 28ms
memory: 39844kb
Test #69:
score: 0
Accepted
time: 357ms
memory: 91860kb
Test #70:
score: 0
Accepted
time: 92ms
memory: 46236kb
Test #71:
score: 0
Accepted
time: 67ms
memory: 46020kb
Test #72:
score: 0
Accepted
time: 28ms
memory: 36668kb
Test #73:
score: 0
Accepted
time: 31ms
memory: 50076kb
Test #74:
score: 0
Accepted
time: 350ms
memory: 84820kb
Test #75:
score: 0
Accepted
time: 101ms
memory: 52980kb
Test #76:
score: 0
Accepted
time: 119ms
memory: 55072kb
Test #77:
score: 0
Accepted
time: 264ms
memory: 73684kb
Test #78:
score: 0
Accepted
time: 25ms
memory: 37504kb
Test #79:
score: 0
Accepted
time: 48ms
memory: 40924kb
Test #80:
score: 0
Accepted
time: 161ms
memory: 56584kb
Test #81:
score: 0
Accepted
time: 65ms
memory: 52448kb
Test #82:
score: 0
Accepted
time: 80ms
memory: 50992kb
Test #83:
score: 0
Accepted
time: 82ms
memory: 48220kb
Test #84:
score: 0
Accepted
time: 49ms
memory: 41440kb
Test #85:
score: 0
Accepted
time: 29ms
memory: 37056kb
Test #86:
score: 0
Accepted
time: 27ms
memory: 38592kb
Test #87:
score: 0
Accepted
time: 48ms
memory: 40624kb
Test #88:
score: 0
Accepted
time: 26ms
memory: 37152kb
Test #89:
score: 0
Accepted
time: 365ms
memory: 83096kb
Test #90:
score: 0
Accepted
time: 91ms
memory: 50716kb
Test #91:
score: 0
Accepted
time: 27ms
memory: 36980kb
Test #92:
score: 0
Accepted
time: 178ms
memory: 76532kb
Test #93:
score: 0
Accepted
time: 32ms
memory: 38996kb
Test #94:
score: 0
Accepted
time: 299ms
memory: 77872kb
Test #95:
score: 0
Accepted
time: 146ms
memory: 71260kb
Test #96:
score: 0
Accepted
time: 79ms
memory: 54152kb
Test #97:
score: 0
Accepted
time: 307ms
memory: 82836kb
Test #98:
score: 0
Accepted
time: 250ms
memory: 70436kb
Test #99:
score: 0
Accepted
time: 99ms
memory: 65292kb
Test #100:
score: 0
Accepted
time: 139ms
memory: 67084kb
Test #101:
score: 0
Accepted
time: 164ms
memory: 79008kb
Test #102:
score: 0
Accepted
time: 117ms
memory: 74616kb
Test #103:
score: 0
Accepted
time: 339ms
memory: 78652kb
Test #104:
score: 0
Accepted
time: 78ms
memory: 44996kb
Test #105:
score: 0
Accepted
time: 130ms
memory: 61592kb
Test #106:
score: 0
Accepted
time: 68ms
memory: 53084kb
Test #107:
score: 0
Accepted
time: 286ms
memory: 73852kb
Test #108:
score: 0
Accepted
time: 369ms
memory: 86604kb
Test #109:
score: 0
Accepted
time: 196ms
memory: 59652kb
Test #110:
score: 0
Accepted
time: 232ms
memory: 77548kb
Test #111:
score: 0
Accepted
time: 148ms
memory: 60076kb
Test #112:
score: 0
Accepted
time: 148ms
memory: 72228kb
Test #113:
score: 0
Accepted
time: 32ms
memory: 35420kb
Test #114:
score: 0
Accepted
time: 27ms
memory: 35480kb
Test #115:
score: 0
Accepted
time: 35ms
memory: 39052kb
Test #116:
score: 0
Accepted
time: 131ms
memory: 71432kb
Test #117:
score: 0
Accepted
time: 179ms
memory: 80612kb
Test #118:
score: 0
Accepted
time: 23ms
memory: 35980kb
Test #119:
score: 0
Accepted
time: 19ms
memory: 34132kb
Test #120:
score: 0
Accepted
time: 272ms
memory: 68060kb
Test #121:
score: 0
Accepted
time: 34ms
memory: 39540kb
Test #122:
score: 0
Accepted
time: 54ms
memory: 51220kb
Test #123:
score: 0
Accepted
time: 30ms
memory: 36980kb
Test #124:
score: 0
Accepted
time: 33ms
memory: 39684kb
Test #125:
score: 0
Accepted
time: 136ms
memory: 50576kb
Test #126:
score: 0
Accepted
time: 26ms
memory: 37936kb
Test #127:
score: 0
Accepted
time: 25ms
memory: 35028kb
Test #128:
score: 0
Accepted
time: 76ms
memory: 58508kb
Test #129:
score: 0
Accepted
time: 40ms
memory: 41756kb
Test #130:
score: 0
Accepted
time: 122ms
memory: 61792kb
Test #131:
score: 0
Accepted
time: 17ms
memory: 36528kb
Test #132:
score: 0
Accepted
time: 177ms
memory: 60424kb
Test #133:
score: 0
Accepted
time: 32ms
memory: 35872kb
Test #134:
score: 0
Accepted
time: 52ms
memory: 45692kb
Test #135:
score: 0
Accepted
time: 334ms
memory: 87720kb
Test #136:
score: 0
Accepted
time: 30ms
memory: 33976kb
Test #137:
score: 0
Accepted
time: 24ms
memory: 39700kb
Test #138:
score: 0
Accepted
time: 349ms
memory: 89292kb
Test #139:
score: 0
Accepted
time: 26ms
memory: 36204kb
Test #140:
score: 0
Accepted
time: 63ms
memory: 49864kb
Test #141:
score: 0
Accepted
time: 218ms
memory: 71732kb
Test #142:
score: 0
Accepted
time: 66ms
memory: 39528kb
Test #143:
score: 0
Accepted
time: 352ms
memory: 91680kb
Test #144:
score: 0
Accepted
time: 105ms
memory: 53692kb
Test #145:
score: 0
Accepted
time: 259ms
memory: 67472kb
Test #146:
score: 0
Accepted
time: 63ms
memory: 44232kb
Test #147:
score: 0
Accepted
time: 204ms
memory: 83528kb
Test #148:
score: 0
Accepted
time: 283ms
memory: 75160kb
Test #149:
score: 0
Accepted
time: 155ms
memory: 62108kb
Test #150:
score: 0
Accepted
time: 304ms
memory: 78600kb
Test #151:
score: 0
Accepted
time: 305ms
memory: 102180kb
Test #152:
score: 0
Accepted
time: 19ms
memory: 38420kb
Test #153:
score: 0
Accepted
time: 38ms
memory: 35572kb
Test #154:
score: 0
Accepted
time: 61ms
memory: 40084kb
Test #155:
score: 0
Accepted
time: 280ms
memory: 74192kb
Test #156:
score: 0
Accepted
time: 49ms
memory: 45404kb
Test #157:
score: 0
Accepted
time: 46ms
memory: 53472kb
Test #158:
score: 0
Accepted
time: 70ms
memory: 50500kb
Test #159:
score: 0
Accepted
time: 19ms
memory: 34700kb
Test #160:
score: 0
Accepted
time: 29ms
memory: 37516kb
Test #161:
score: 0
Accepted
time: 95ms
memory: 48288kb
Test #162:
score: 0
Accepted
time: 35ms
memory: 39056kb
Test #163:
score: 0
Accepted
time: 17ms
memory: 33108kb
Test #164:
score: 0
Accepted
time: 151ms
memory: 58248kb
Test #165:
score: 0
Accepted
time: 285ms
memory: 80152kb
Test #166:
score: 0
Accepted
time: 287ms
memory: 71632kb