QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#17943#2213. Knightnamelessgugugu#WA 71ms14392kbC++141.7kb2022-01-15 13:40:522022-05-04 16:29:54

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-04 16:29:54]
  • 评测
  • 测评结果:WA
  • 用时:71ms
  • 内存:14392kb
  • [2022-01-15 13:40:52]
  • 提交

answer

#include <cstdio>
#include <cstring>
#include <algorithm>
const int N = 1005;
int n, m, r, c, pa, pb;
char s[N][N];
int fa[N * N], val[N * N], siz[N * N];
inline int find(int x)
{
    if(fa[x] == x)
        return x;
    int res = find(fa[x]);
    val[x] ^= val[fa[x]];
    return fa[x] = res;
}
inline void merge(int x, int y)
{
    x = find(x), y = find(y);
    if(x == y)
        return;
    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);
    int dx[] = {r, r, -r, -r, c, c, -c, -c};
    int dy[] = {c, -c, c, -c, r, -r, r, -r};
    for (int i = 1; i <= n * m;++i)
        fa[i] = i, val[i] = 1, siz[i] = 1;
    for (int x = 1; x <= n;++x)
        for (int y = 1; y <= m;++y)
            if(s[x][y] != '@')
            {
                for (int k = 0; k < 8;++k)
                {
                    int nx = x + dx[k], ny = y + dy[k];
                    if(nx < 1 || ny < 1 || nx > n || ny > m || s[nx][ny] == '@')
                        continue;
                    merge((x - 1) * m + y, (nx - 1) * m + ny);
                }
            }
    for (int x = 1; x <= n; ++x)
        for (int y = 1; y <= m; ++y)
            if (s[x][y] == 'A')
            {
                pa = (x - 1) * m + y;
            }
            else if(s[x][y] == 'B')
            {
                pb = (x - 1) * m + y;
            }
    if(siz[find(pa)] == 1)
        return puts("Bob"), 0;
    if(find(pa) != find(pb))
        return puts("Alice"), 0;
    find(pa), find(pb);
    puts(val[pa] == val[pb] ? "Alice" : "Bob");
    return 0;
}

Details

Test #1:

score: 100
Accepted
time: 12ms
memory: 13820kb

Test #2:

score: 0
Accepted
time: 4ms
memory: 9888kb

Test #3:

score: 0
Accepted
time: 42ms
memory: 13912kb

Test #4:

score: 0
Accepted
time: 39ms
memory: 14104kb

Test #5:

score: 0
Accepted
time: 2ms
memory: 5632kb

Test #6:

score: 0
Accepted
time: 6ms
memory: 7148kb

Test #7:

score: 0
Accepted
time: 1ms
memory: 5820kb

Test #8:

score: 0
Accepted
time: 6ms
memory: 6744kb

Test #9:

score: 0
Accepted
time: 17ms
memory: 13912kb

Test #10:

score: 0
Accepted
time: 10ms
memory: 14056kb

Test #11:

score: 0
Accepted
time: 10ms
memory: 14240kb

Test #12:

score: 0
Accepted
time: 17ms
memory: 13692kb

Test #13:

score: 0
Accepted
time: 7ms
memory: 6416kb

Test #14:

score: 0
Accepted
time: 14ms
memory: 14392kb

Test #15:

score: 0
Accepted
time: 3ms
memory: 8064kb

Test #16:

score: 0
Accepted
time: 8ms
memory: 14136kb

Test #17:

score: 0
Accepted
time: 3ms
memory: 5904kb

Test #18:

score: 0
Accepted
time: 3ms
memory: 6568kb

Test #19:

score: 0
Accepted
time: 2ms
memory: 5996kb

Test #20:

score: 0
Accepted
time: 14ms
memory: 11540kb

Test #21:

score: 0
Accepted
time: 1ms
memory: 5760kb

Test #22:

score: 0
Accepted
time: 0ms
memory: 6924kb

Test #23:

score: 0
Accepted
time: 3ms
memory: 5776kb

Test #24:

score: 0
Accepted
time: 7ms
memory: 13568kb

Test #25:

score: 0
Accepted
time: 6ms
memory: 6992kb

Test #26:

score: 0
Accepted
time: 3ms
memory: 7784kb

Test #27:

score: 0
Accepted
time: 1ms
memory: 5796kb

Test #28:

score: 0
Accepted
time: 55ms
memory: 9732kb

Test #29:

score: 0
Accepted
time: 9ms
memory: 12996kb

Test #30:

score: 0
Accepted
time: 12ms
memory: 13728kb

Test #31:

score: 0
Accepted
time: 3ms
memory: 12676kb

Test #32:

score: 0
Accepted
time: 2ms
memory: 5816kb

Test #33:

score: 0
Accepted
time: 40ms
memory: 14140kb

Test #34:

score: 0
Accepted
time: 9ms
memory: 12252kb

Test #35:

score: 0
Accepted
time: 29ms
memory: 13296kb

Test #36:

score: 0
Accepted
time: 71ms
memory: 14384kb

Test #37:

score: 0
Accepted
time: 1ms
memory: 6860kb

Test #38:

score: -100
Wrong Answer
time: 12ms
memory: 12380kb