QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#17929 | #2213. Knight | CharlieVinnie# | AC ✓ | 437ms | 97760kb | C++14 | 1.3kb | 2022-01-15 12:41:29 | 2022-05-04 16:25:52 |
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 cv)
{
col[u]=cv;
for(auto v:to[u]){
if(col[v]) continue;
dfs(v,3-cv);
}
}
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);
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;
}
Details
Test #1:
score: 100
Accepted
time: 46ms
memory: 46720kb
Test #2:
score: 0
Accepted
time: 4ms
memory: 30320kb
Test #3:
score: 0
Accepted
time: 131ms
memory: 54560kb
Test #4:
score: 0
Accepted
time: 70ms
memory: 44532kb
Test #5:
score: 0
Accepted
time: 4ms
memory: 30256kb
Test #6:
score: 0
Accepted
time: 16ms
memory: 35452kb
Test #7:
score: 0
Accepted
time: 8ms
memory: 30500kb
Test #8:
score: 0
Accepted
time: 9ms
memory: 30752kb
Test #9:
score: 0
Accepted
time: 46ms
memory: 41908kb
Test #10:
score: 0
Accepted
time: 17ms
memory: 34124kb
Test #11:
score: 0
Accepted
time: 8ms
memory: 33368kb
Test #12:
score: 0
Accepted
time: 70ms
memory: 52684kb
Test #13:
score: 0
Accepted
time: 24ms
memory: 36928kb
Test #14:
score: 0
Accepted
time: 46ms
memory: 45200kb
Test #15:
score: 0
Accepted
time: 4ms
memory: 33980kb
Test #16:
score: 0
Accepted
time: 26ms
memory: 33876kb
Test #17:
score: 0
Accepted
time: 4ms
memory: 30272kb
Test #18:
score: 0
Accepted
time: 18ms
memory: 38064kb
Test #19:
score: 0
Accepted
time: 12ms
memory: 31184kb
Test #20:
score: 0
Accepted
time: 21ms
memory: 41992kb
Test #21:
score: 0
Accepted
time: 6ms
memory: 30348kb
Test #22:
score: 0
Accepted
time: 15ms
memory: 32612kb
Test #23:
score: 0
Accepted
time: 3ms
memory: 30424kb
Test #24:
score: 0
Accepted
time: 7ms
memory: 32460kb
Test #25:
score: 0
Accepted
time: 7ms
memory: 33404kb
Test #26:
score: 0
Accepted
time: 5ms
memory: 30276kb
Test #27:
score: 0
Accepted
time: 8ms
memory: 30240kb
Test #28:
score: 0
Accepted
time: 119ms
memory: 53592kb
Test #29:
score: 0
Accepted
time: 16ms
memory: 32896kb
Test #30:
score: 0
Accepted
time: 20ms
memory: 33180kb
Test #31:
score: 0
Accepted
time: 18ms
memory: 32120kb
Test #32:
score: 0
Accepted
time: 4ms
memory: 28464kb
Test #33:
score: 0
Accepted
time: 100ms
memory: 49668kb
Test #34:
score: 0
Accepted
time: 9ms
memory: 33332kb
Test #35:
score: 0
Accepted
time: 96ms
memory: 46264kb
Test #36:
score: 0
Accepted
time: 81ms
memory: 49440kb
Test #37:
score: 0
Accepted
time: 11ms
memory: 30592kb
Test #38:
score: 0
Accepted
time: 25ms
memory: 33720kb
Test #39:
score: 0
Accepted
time: 7ms
memory: 28964kb
Test #40:
score: 0
Accepted
time: 7ms
memory: 30952kb
Test #41:
score: 0
Accepted
time: 25ms
memory: 34480kb
Test #42:
score: 0
Accepted
time: 21ms
memory: 33012kb
Test #43:
score: 0
Accepted
time: 26ms
memory: 36564kb
Test #44:
score: 0
Accepted
time: 13ms
memory: 30756kb
Test #45:
score: 0
Accepted
time: 3ms
memory: 32248kb
Test #46:
score: 0
Accepted
time: 5ms
memory: 29960kb
Test #47:
score: 0
Accepted
time: 9ms
memory: 31416kb
Test #48:
score: 0
Accepted
time: 88ms
memory: 47616kb
Test #49:
score: 0
Accepted
time: 34ms
memory: 40000kb
Test #50:
score: 0
Accepted
time: 21ms
memory: 33952kb
Test #51:
score: 0
Accepted
time: 253ms
memory: 66352kb
Test #52:
score: 0
Accepted
time: 217ms
memory: 65304kb
Test #53:
score: 0
Accepted
time: 33ms
memory: 39400kb
Test #54:
score: 0
Accepted
time: 279ms
memory: 84864kb
Test #55:
score: 0
Accepted
time: 111ms
memory: 52096kb
Test #56:
score: 0
Accepted
time: 369ms
memory: 82184kb
Test #57:
score: 0
Accepted
time: 163ms
memory: 51784kb
Test #58:
score: 0
Accepted
time: 29ms
memory: 36548kb
Test #59:
score: 0
Accepted
time: 51ms
memory: 37124kb
Test #60:
score: 0
Accepted
time: 391ms
memory: 85648kb
Test #61:
score: 0
Accepted
time: 87ms
memory: 48864kb
Test #62:
score: 0
Accepted
time: 62ms
memory: 43352kb
Test #63:
score: 0
Accepted
time: 291ms
memory: 68448kb
Test #64:
score: 0
Accepted
time: 42ms
memory: 38260kb
Test #65:
score: 0
Accepted
time: 175ms
memory: 77720kb
Test #66:
score: 0
Accepted
time: 38ms
memory: 37344kb
Test #67:
score: 0
Accepted
time: 120ms
memory: 56356kb
Test #68:
score: 0
Accepted
time: 62ms
memory: 39968kb
Test #69:
score: 0
Accepted
time: 350ms
memory: 89088kb
Test #70:
score: 0
Accepted
time: 96ms
memory: 44840kb
Test #71:
score: 0
Accepted
time: 71ms
memory: 45204kb
Test #72:
score: 0
Accepted
time: 34ms
memory: 37232kb
Test #73:
score: 0
Accepted
time: 79ms
memory: 51220kb
Test #74:
score: 0
Accepted
time: 356ms
memory: 82800kb
Test #75:
score: 0
Accepted
time: 100ms
memory: 54240kb
Test #76:
score: 0
Accepted
time: 131ms
memory: 55416kb
Test #77:
score: 0
Accepted
time: 314ms
memory: 73912kb
Test #78:
score: 0
Accepted
time: 39ms
memory: 36624kb
Test #79:
score: 0
Accepted
time: 66ms
memory: 42728kb
Test #80:
score: 0
Accepted
time: 183ms
memory: 57360kb
Test #81:
score: 0
Accepted
time: 108ms
memory: 52076kb
Test #82:
score: 0
Accepted
time: 103ms
memory: 50732kb
Test #83:
score: 0
Accepted
time: 82ms
memory: 49096kb
Test #84:
score: 0
Accepted
time: 67ms
memory: 41456kb
Test #85:
score: 0
Accepted
time: 47ms
memory: 37764kb
Test #86:
score: 0
Accepted
time: 40ms
memory: 38592kb
Test #87:
score: 0
Accepted
time: 48ms
memory: 41176kb
Test #88:
score: 0
Accepted
time: 44ms
memory: 37208kb
Test #89:
score: 0
Accepted
time: 389ms
memory: 82404kb
Test #90:
score: 0
Accepted
time: 101ms
memory: 50612kb
Test #91:
score: 0
Accepted
time: 38ms
memory: 36320kb
Test #92:
score: 0
Accepted
time: 208ms
memory: 76624kb
Test #93:
score: 0
Accepted
time: 52ms
memory: 39848kb
Test #94:
score: 0
Accepted
time: 326ms
memory: 76972kb
Test #95:
score: 0
Accepted
time: 155ms
memory: 72104kb
Test #96:
score: 0
Accepted
time: 95ms
memory: 55216kb
Test #97:
score: 0
Accepted
time: 273ms
memory: 79828kb
Test #98:
score: 0
Accepted
time: 281ms
memory: 71384kb
Test #99:
score: 0
Accepted
time: 124ms
memory: 65624kb
Test #100:
score: 0
Accepted
time: 135ms
memory: 67216kb
Test #101:
score: 0
Accepted
time: 187ms
memory: 79552kb
Test #102:
score: 0
Accepted
time: 175ms
memory: 75596kb
Test #103:
score: 0
Accepted
time: 292ms
memory: 78276kb
Test #104:
score: 0
Accepted
time: 79ms
memory: 44148kb
Test #105:
score: 0
Accepted
time: 148ms
memory: 61524kb
Test #106:
score: 0
Accepted
time: 98ms
memory: 52716kb
Test #107:
score: 0
Accepted
time: 293ms
memory: 74780kb
Test #108:
score: 0
Accepted
time: 367ms
memory: 84596kb
Test #109:
score: 0
Accepted
time: 203ms
memory: 59588kb
Test #110:
score: 0
Accepted
time: 258ms
memory: 76696kb
Test #111:
score: 0
Accepted
time: 183ms
memory: 60380kb
Test #112:
score: 0
Accepted
time: 179ms
memory: 72468kb
Test #113:
score: 0
Accepted
time: 34ms
memory: 37584kb
Test #114:
score: 0
Accepted
time: 45ms
memory: 37012kb
Test #115:
score: 0
Accepted
time: 49ms
memory: 39728kb
Test #116:
score: 0
Accepted
time: 157ms
memory: 71668kb
Test #117:
score: 0
Accepted
time: 200ms
memory: 81088kb
Test #118:
score: 0
Accepted
time: 38ms
memory: 34664kb
Test #119:
score: 0
Accepted
time: 31ms
memory: 34424kb
Test #120:
score: 0
Accepted
time: 239ms
memory: 67376kb
Test #121:
score: 0
Accepted
time: 48ms
memory: 39856kb
Test #122:
score: 0
Accepted
time: 69ms
memory: 51856kb
Test #123:
score: 0
Accepted
time: 41ms
memory: 38608kb
Test #124:
score: 0
Accepted
time: 64ms
memory: 41508kb
Test #125:
score: 0
Accepted
time: 129ms
memory: 50896kb
Test #126:
score: 0
Accepted
time: 41ms
memory: 37604kb
Test #127:
score: 0
Accepted
time: 38ms
memory: 34100kb
Test #128:
score: 0
Accepted
time: 80ms
memory: 57892kb
Test #129:
score: 0
Accepted
time: 50ms
memory: 40524kb
Test #130:
score: 0
Accepted
time: 159ms
memory: 62280kb
Test #131:
score: 0
Accepted
time: 40ms
memory: 37672kb
Test #132:
score: 0
Accepted
time: 201ms
memory: 59152kb
Test #133:
score: 0
Accepted
time: 45ms
memory: 36908kb
Test #134:
score: 0
Accepted
time: 70ms
memory: 45328kb
Test #135:
score: 0
Accepted
time: 437ms
memory: 85408kb
Test #136:
score: 0
Accepted
time: 33ms
memory: 36256kb
Test #137:
score: 0
Accepted
time: 51ms
memory: 39568kb
Test #138:
score: 0
Accepted
time: 366ms
memory: 87420kb
Test #139:
score: 0
Accepted
time: 41ms
memory: 37220kb
Test #140:
score: 0
Accepted
time: 64ms
memory: 49848kb
Test #141:
score: 0
Accepted
time: 197ms
memory: 72116kb
Test #142:
score: 0
Accepted
time: 74ms
memory: 41200kb
Test #143:
score: 0
Accepted
time: 408ms
memory: 89416kb
Test #144:
score: 0
Accepted
time: 137ms
memory: 54540kb
Test #145:
score: 0
Accepted
time: 267ms
memory: 67348kb
Test #146:
score: 0
Accepted
time: 75ms
memory: 46008kb
Test #147:
score: 0
Accepted
time: 220ms
memory: 83424kb
Test #148:
score: 0
Accepted
time: 319ms
memory: 75984kb
Test #149:
score: 0
Accepted
time: 162ms
memory: 63176kb
Test #150:
score: 0
Accepted
time: 328ms
memory: 77236kb
Test #151:
score: 0
Accepted
time: 359ms
memory: 97760kb
Test #152:
score: 0
Accepted
time: 37ms
memory: 36780kb
Test #153:
score: 0
Accepted
time: 47ms
memory: 38472kb
Test #154:
score: 0
Accepted
time: 66ms
memory: 42708kb
Test #155:
score: 0
Accepted
time: 283ms
memory: 72792kb
Test #156:
score: 0
Accepted
time: 91ms
memory: 45796kb
Test #157:
score: 0
Accepted
time: 59ms
memory: 52204kb
Test #158:
score: 0
Accepted
time: 96ms
memory: 49284kb
Test #159:
score: 0
Accepted
time: 31ms
memory: 36920kb
Test #160:
score: 0
Accepted
time: 38ms
memory: 37436kb
Test #161:
score: 0
Accepted
time: 95ms
memory: 47476kb
Test #162:
score: 0
Accepted
time: 40ms
memory: 39144kb
Test #163:
score: 0
Accepted
time: 35ms
memory: 34680kb
Test #164:
score: 0
Accepted
time: 140ms
memory: 58036kb
Test #165:
score: 0
Accepted
time: 289ms
memory: 79976kb
Test #166:
score: 0
Accepted
time: 276ms
memory: 71164kb