QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#53001 | #2213. Knight | namelessgugugu# | AC ✓ | 106ms | 18284kb | C++14 | 1.4kb | 2022-10-04 17:01:13 | 2022-10-04 17:01:16 |
Judging History
answer
#include <cstdio>
#include <cstring>
#include <algorithm>
const int N = 1005, M = 1000005;
int n, m, r, c;
char s[N][N];
int fa[M << 1], siz[M << 1];
inline int id(int x, int y)
{
return (x - 1) * m + y;
}
inline void init(int l)
{
for(int i = 1;i <= l;++i)
fa[i] = i, siz[i] = 1;
return;
}
int find(int x)
{
return fa[x] == x ? x : fa[x] = find(fa[x]);
}
inline void merge(int x, int y)
{
x = find(x), y = find(y);
if(x == y)
return;
if(siz[x] > siz[y])
std::swap(x, y);
fa[x] = y, siz[y] += siz[x];
return;
}
int main(void)
{
scanf("%d%d%d%d", &n, &m, &r, &c);
for(int i = 1;i <= n;++i)
scanf("%s", s[i] + 1);
init(2 * n * m);
for(int x = 1;x <= n;++x)
for(int y = 1;y <= m;++y)
if(s[x][y] != '@')
{
const int dx[8] = {r, r, -r, -r, c, c, -c, -c};
const int dy[8] = {c, -c, c, -c, r, -r, r, -r};
for(int o = 0;o < 8;++o)
{
int nx = x + dx[o], ny = y + dy[o];
if(nx < 1 || nx > n || ny < 1 || ny > m || s[nx][ny] == '@')
continue;
merge(id(x, y), id(nx, ny) + n * m);
merge(id(nx, ny), id(x, y) + n * m);
}
}
int sa = 0, sb = 0;
for(int i = 1;i <= n;++i)
for(int j = 1;j <= m;++j)
if(s[i][j] == 'A')
sa = id(i, j);
else if(s[i][j] == 'B')
sb = id(i, j);
if(find(sa) == find(sb + n * m) || siz[find(sa)] == 1)
puts("Bob");
else
puts("Alice");
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 23ms
memory: 10444kb
Test #2:
score: 0
Accepted
time: 1ms
memory: 1988kb
Test #3:
score: 0
Accepted
time: 27ms
memory: 10064kb
Test #4:
score: 0
Accepted
time: 30ms
memory: 8980kb
Test #5:
score: 0
Accepted
time: 1ms
memory: 1840kb
Test #6:
score: 0
Accepted
time: 12ms
memory: 5812kb
Test #7:
score: 0
Accepted
time: 2ms
memory: 1984kb
Test #8:
score: 0
Accepted
time: 3ms
memory: 5236kb
Test #9:
score: 0
Accepted
time: 21ms
memory: 15136kb
Test #10:
score: 0
Accepted
time: 6ms
memory: 10896kb
Test #11:
score: 0
Accepted
time: 7ms
memory: 5628kb
Test #12:
score: 0
Accepted
time: 22ms
memory: 13384kb
Test #13:
score: 0
Accepted
time: 6ms
memory: 3376kb
Test #14:
score: 0
Accepted
time: 15ms
memory: 13888kb
Test #15:
score: 0
Accepted
time: 2ms
memory: 3576kb
Test #16:
score: 0
Accepted
time: 16ms
memory: 10760kb
Test #17:
score: 0
Accepted
time: 2ms
memory: 2220kb
Test #18:
score: 0
Accepted
time: 2ms
memory: 3844kb
Test #19:
score: 0
Accepted
time: 1ms
memory: 2356kb
Test #20:
score: 0
Accepted
time: 11ms
memory: 8008kb
Test #21:
score: 0
Accepted
time: 1ms
memory: 1832kb
Test #22:
score: 0
Accepted
time: 3ms
memory: 5488kb
Test #23:
score: 0
Accepted
time: 1ms
memory: 2004kb
Test #24:
score: 0
Accepted
time: 5ms
memory: 9504kb
Test #25:
score: 0
Accepted
time: 5ms
memory: 4308kb
Test #26:
score: 0
Accepted
time: 0ms
memory: 1892kb
Test #27:
score: 0
Accepted
time: 1ms
memory: 1844kb
Test #28:
score: 0
Accepted
time: 27ms
memory: 7884kb
Test #29:
score: 0
Accepted
time: 7ms
memory: 6356kb
Test #30:
score: 0
Accepted
time: 11ms
memory: 11380kb
Test #31:
score: 0
Accepted
time: 9ms
memory: 5276kb
Test #32:
score: 0
Accepted
time: 0ms
memory: 1860kb
Test #33:
score: 0
Accepted
time: 31ms
memory: 10108kb
Test #34:
score: 0
Accepted
time: 0ms
memory: 5244kb
Test #35:
score: 0
Accepted
time: 23ms
memory: 8136kb
Test #36:
score: 0
Accepted
time: 59ms
memory: 15596kb
Test #37:
score: 0
Accepted
time: 7ms
memory: 5076kb
Test #38:
score: 0
Accepted
time: 9ms
memory: 4644kb
Test #39:
score: 0
Accepted
time: 0ms
memory: 2216kb
Test #40:
score: 0
Accepted
time: 4ms
memory: 4024kb
Test #41:
score: 0
Accepted
time: 15ms
memory: 9424kb
Test #42:
score: 0
Accepted
time: 3ms
memory: 6196kb
Test #43:
score: 0
Accepted
time: 14ms
memory: 11940kb
Test #44:
score: 0
Accepted
time: 2ms
memory: 3580kb
Test #45:
score: 0
Accepted
time: 3ms
memory: 3296kb
Test #46:
score: 0
Accepted
time: 2ms
memory: 2288kb
Test #47:
score: 0
Accepted
time: 4ms
memory: 3052kb
Test #48:
score: 0
Accepted
time: 33ms
memory: 13340kb
Test #49:
score: 0
Accepted
time: 15ms
memory: 12712kb
Test #50:
score: 0
Accepted
time: 9ms
memory: 5592kb
Test #51:
score: 0
Accepted
time: 70ms
memory: 18128kb
Test #52:
score: 0
Accepted
time: 68ms
memory: 18208kb
Test #53:
score: 0
Accepted
time: 38ms
memory: 18200kb
Test #54:
score: 0
Accepted
time: 53ms
memory: 18216kb
Test #55:
score: 0
Accepted
time: 69ms
memory: 18232kb
Test #56:
score: 0
Accepted
time: 56ms
memory: 18204kb
Test #57:
score: 0
Accepted
time: 70ms
memory: 18208kb
Test #58:
score: 0
Accepted
time: 23ms
memory: 18216kb
Test #59:
score: 0
Accepted
time: 28ms
memory: 18132kb
Test #60:
score: 0
Accepted
time: 59ms
memory: 18176kb
Test #61:
score: 0
Accepted
time: 63ms
memory: 18280kb
Test #62:
score: 0
Accepted
time: 56ms
memory: 18204kb
Test #63:
score: 0
Accepted
time: 71ms
memory: 18232kb
Test #64:
score: 0
Accepted
time: 28ms
memory: 18208kb
Test #65:
score: 0
Accepted
time: 61ms
memory: 18212kb
Test #66:
score: 0
Accepted
time: 27ms
memory: 18124kb
Test #67:
score: 0
Accepted
time: 62ms
memory: 18204kb
Test #68:
score: 0
Accepted
time: 27ms
memory: 18232kb
Test #69:
score: 0
Accepted
time: 57ms
memory: 18176kb
Test #70:
score: 0
Accepted
time: 49ms
memory: 18216kb
Test #71:
score: 0
Accepted
time: 37ms
memory: 18176kb
Test #72:
score: 0
Accepted
time: 20ms
memory: 18220kb
Test #73:
score: 0
Accepted
time: 20ms
memory: 18216kb
Test #74:
score: 0
Accepted
time: 58ms
memory: 18224kb
Test #75:
score: 0
Accepted
time: 65ms
memory: 18224kb
Test #76:
score: 0
Accepted
time: 69ms
memory: 18136kb
Test #77:
score: 0
Accepted
time: 51ms
memory: 18224kb
Test #78:
score: 0
Accepted
time: 21ms
memory: 18204kb
Test #79:
score: 0
Accepted
time: 50ms
memory: 18224kb
Test #80:
score: 0
Accepted
time: 60ms
memory: 18276kb
Test #81:
score: 0
Accepted
time: 59ms
memory: 18132kb
Test #82:
score: 0
Accepted
time: 53ms
memory: 18208kb
Test #83:
score: 0
Accepted
time: 59ms
memory: 18132kb
Test #84:
score: 0
Accepted
time: 45ms
memory: 18208kb
Test #85:
score: 0
Accepted
time: 39ms
memory: 18232kb
Test #86:
score: 0
Accepted
time: 28ms
memory: 18232kb
Test #87:
score: 0
Accepted
time: 21ms
memory: 18228kb
Test #88:
score: 0
Accepted
time: 27ms
memory: 18212kb
Test #89:
score: 0
Accepted
time: 47ms
memory: 18280kb
Test #90:
score: 0
Accepted
time: 74ms
memory: 18224kb
Test #91:
score: 0
Accepted
time: 36ms
memory: 18228kb
Test #92:
score: 0
Accepted
time: 69ms
memory: 18200kb
Test #93:
score: 0
Accepted
time: 19ms
memory: 18224kb
Test #94:
score: 0
Accepted
time: 65ms
memory: 18232kb
Test #95:
score: 0
Accepted
time: 66ms
memory: 18280kb
Test #96:
score: 0
Accepted
time: 66ms
memory: 18216kb
Test #97:
score: 0
Accepted
time: 66ms
memory: 18208kb
Test #98:
score: 0
Accepted
time: 51ms
memory: 18280kb
Test #99:
score: 0
Accepted
time: 82ms
memory: 18228kb
Test #100:
score: 0
Accepted
time: 51ms
memory: 18232kb
Test #101:
score: 0
Accepted
time: 57ms
memory: 18232kb
Test #102:
score: 0
Accepted
time: 52ms
memory: 18224kb
Test #103:
score: 0
Accepted
time: 50ms
memory: 18224kb
Test #104:
score: 0
Accepted
time: 70ms
memory: 18232kb
Test #105:
score: 0
Accepted
time: 66ms
memory: 18136kb
Test #106:
score: 0
Accepted
time: 48ms
memory: 18220kb
Test #107:
score: 0
Accepted
time: 57ms
memory: 18176kb
Test #108:
score: 0
Accepted
time: 58ms
memory: 18212kb
Test #109:
score: 0
Accepted
time: 65ms
memory: 18232kb
Test #110:
score: 0
Accepted
time: 95ms
memory: 18232kb
Test #111:
score: 0
Accepted
time: 106ms
memory: 18284kb
Test #112:
score: 0
Accepted
time: 51ms
memory: 18216kb
Test #113:
score: 0
Accepted
time: 39ms
memory: 18224kb
Test #114:
score: 0
Accepted
time: 16ms
memory: 18204kb
Test #115:
score: 0
Accepted
time: 34ms
memory: 18124kb
Test #116:
score: 0
Accepted
time: 57ms
memory: 18228kb
Test #117:
score: 0
Accepted
time: 60ms
memory: 18128kb
Test #118:
score: 0
Accepted
time: 10ms
memory: 18232kb
Test #119:
score: 0
Accepted
time: 10ms
memory: 18208kb
Test #120:
score: 0
Accepted
time: 61ms
memory: 18176kb
Test #121:
score: 0
Accepted
time: 19ms
memory: 18232kb
Test #122:
score: 0
Accepted
time: 39ms
memory: 18204kb
Test #123:
score: 0
Accepted
time: 27ms
memory: 18220kb
Test #124:
score: 0
Accepted
time: 30ms
memory: 18120kb
Test #125:
score: 0
Accepted
time: 62ms
memory: 18232kb
Test #126:
score: 0
Accepted
time: 21ms
memory: 18200kb
Test #127:
score: 0
Accepted
time: 8ms
memory: 18208kb
Test #128:
score: 0
Accepted
time: 33ms
memory: 18212kb
Test #129:
score: 0
Accepted
time: 32ms
memory: 18228kb
Test #130:
score: 0
Accepted
time: 70ms
memory: 18136kb
Test #131:
score: 0
Accepted
time: 16ms
memory: 18224kb
Test #132:
score: 0
Accepted
time: 57ms
memory: 18232kb
Test #133:
score: 0
Accepted
time: 21ms
memory: 18228kb
Test #134:
score: 0
Accepted
time: 41ms
memory: 18224kb
Test #135:
score: 0
Accepted
time: 70ms
memory: 18232kb
Test #136:
score: 0
Accepted
time: 15ms
memory: 18132kb
Test #137:
score: 0
Accepted
time: 28ms
memory: 18212kb
Test #138:
score: 0
Accepted
time: 58ms
memory: 18200kb
Test #139:
score: 0
Accepted
time: 32ms
memory: 18216kb
Test #140:
score: 0
Accepted
time: 38ms
memory: 18224kb
Test #141:
score: 0
Accepted
time: 63ms
memory: 18236kb
Test #142:
score: 0
Accepted
time: 41ms
memory: 18228kb
Test #143:
score: 0
Accepted
time: 63ms
memory: 18228kb
Test #144:
score: 0
Accepted
time: 59ms
memory: 18128kb
Test #145:
score: 0
Accepted
time: 45ms
memory: 18232kb
Test #146:
score: 0
Accepted
time: 57ms
memory: 18120kb
Test #147:
score: 0
Accepted
time: 64ms
memory: 18228kb
Test #148:
score: 0
Accepted
time: 52ms
memory: 18216kb
Test #149:
score: 0
Accepted
time: 44ms
memory: 18204kb
Test #150:
score: 0
Accepted
time: 52ms
memory: 18236kb
Test #151:
score: 0
Accepted
time: 69ms
memory: 18220kb
Test #152:
score: 0
Accepted
time: 20ms
memory: 18232kb
Test #153:
score: 0
Accepted
time: 28ms
memory: 18208kb
Test #154:
score: 0
Accepted
time: 38ms
memory: 18180kb
Test #155:
score: 0
Accepted
time: 70ms
memory: 18228kb
Test #156:
score: 0
Accepted
time: 40ms
memory: 18228kb
Test #157:
score: 0
Accepted
time: 26ms
memory: 18228kb
Test #158:
score: 0
Accepted
time: 50ms
memory: 18132kb
Test #159:
score: 0
Accepted
time: 17ms
memory: 18228kb
Test #160:
score: 0
Accepted
time: 25ms
memory: 18204kb
Test #161:
score: 0
Accepted
time: 41ms
memory: 18220kb
Test #162:
score: 0
Accepted
time: 33ms
memory: 18228kb
Test #163:
score: 0
Accepted
time: 11ms
memory: 18176kb
Test #164:
score: 0
Accepted
time: 54ms
memory: 18128kb
Test #165:
score: 0
Accepted
time: 55ms
memory: 18208kb
Test #166:
score: 0
Accepted
time: 63ms
memory: 18232kb