QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#233902#7635. Fairy Chessucup-team635WA 38ms3872kbC++232.4kb2023-11-01 06:38:432023-11-01 06:38:44

Judging History

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

  • [2023-11-01 06:38:44]
  • 评测
  • 测评结果:WA
  • 用时:38ms
  • 内存:3872kb
  • [2023-11-01 06:38:43]
  • 提交

answer

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstdint>
#include <iostream>
#include <limits>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
#include <array>

using namespace std;

using i64 = int64_t;
using u64 = uint64_t;
using i32 = int32_t;
using u32 = uint32_t;

#define REP(i, s, t) for (i32 i = (s); i < (t); ++i)

template <class T>
std::vector<T> vec(T elem, int len) {
    return std::vector<T>(len, elem);
}

u64 hit[6][64] = {};
array<i32, 12> a;

bool calc(const u64 ban, const u64 elem, const i32 k) {
    REP(i, 0, 64) {
        if (((ban >> i) & 1) == 1) continue;
        const u64 mask = hit[a[k]][i];
        if ((mask & elem) > 0) continue;
        if (!calc(ban | mask, elem | ((u64)1 << i), k + 1)) return true;
    }
    return false;
}

void run(void) {
    const i32 n = 8;
    auto pos = [](const i32 x, const i32 y) -> i32 {
        assert(0 <= x && x < n);
        assert(0 <= y && y < n);
        return x * 8 + y;
    };
    REP(x, 0, n) {
        REP(y, 0, n) {
            u64 a = 0;
            REP(i, 0, n) {
                a |= (u64)1 << pos(x, i);
                a |= (u64)1 << pos(i, y);
            }
            u64 b = 0;
            REP(i, 0, n) {
                REP(j, 0, n) {
                    if (x + y == i + j || x - y == i - j) {
                        b |= (u64)1 << pos(i, j);
                    }
                }
            }
            u64 c = 0;
            REP(i, 0, n) {
                REP(j, 0, n) {
                    const i32 dx = x - i;
                    const i32 dy = y - j;
                    if (dx * dx + dy * dy == 5) {
                        c |= (u64)1 << pos(i, j);
                    }
                }
            }
            hit[0][pos(x, y)] = a;
            hit[1][pos(x, y)] = b;
            hit[2][pos(x, y)] = a | b;
            REP(i, 3, 6) {
                hit[i][pos(x, y)] = hit[i - 3][pos(x, y)] | c;
            }
        }
    }
    const string t = "RBQCAM";
    string s;
    cin >> s;
    array<i32, 12> a;
    REP(i, 0, 12) {
        REP(j, 0, 6) {
            if (s[i] == t[j]) {
                a[i] = j;
            }
        }
    }
    cout << (calc(0, 0, 0) ? "Alice" : "Bob") << "\n";
}

int main(void) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    run();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 38ms
memory: 3536kb

input:

BBAARRCCQQMM

output:

Bob

result:

ok single line: 'Bob'

Test #2:

score: -100
Wrong Answer
time: 38ms
memory: 3872kb

input:

BAMBAMQQRCCR

output:

Bob

result:

wrong answer 1st lines differ - expected: 'Alice', found: 'Bob'