QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#228118#7635. Fairy Chessucup-team133#WA 1ms3568kbC++202.5kb2023-10-28 12:16:332023-10-28 12:16:34

Judging History

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

  • [2023-10-28 12:16:34]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3568kb
  • [2023-10-28 12:16:33]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(), (x).end()
using ll = long long;

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    for (int i = 0; i < (int) v.size(); i++) {
        os << v[i] << (i + 1 == (int) v.size() ? "" : " ");
    }
    return os;
}

#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;
#else
#define debug()
#endif

using ull = unsigned long long;
const int MAX = 8, PIECE = 6;

int f(int x, int y) { return x * MAX + y; }

int ctoi(char c) {
    if (c == 'B') return 0;
    if (c == 'R') return 1;
    if (c == 'Q') return 2;
    if (c == 'A') return 3;
    if (c == 'C') return 4;
    if (c == 'M') return 5;
    assert(false);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    vector mass(PIECE + 1, vector(MAX, vector<ull>(MAX, 0)));
    vector<vector<ull>> nxt(PIECE);
    for (int x = 0; x < MAX; x++) {
        for (int y = 0; y < MAX; y++) {
            for (int nx = 0; nx < MAX; nx++) {
                for (int ny = 0; ny < MAX; ny++) {
                    if (x - y == nx - ny or x + y == nx + ny) mass[0][x][y] |= 1ULL << f(nx, ny);
                    if (x == nx or y == ny) mass[1][x][y] |= 1ULL << f(nx, ny);
                    if (x == nx and y == ny) mass[6][x][y] |= 1ULL << f(nx, ny);
                    if (abs(x - nx) == 2 and abs(y - ny) == 1) mass[6][x][y] |= 1ULL << f(nx, ny);
                    else if (abs(x - nx) == 1 and abs(y - ny) == 2) mass[6][x][y] |= 1ULL << f(nx, ny);
                }
            }
            mass[2][x][y] = mass[0][x][y] | mass[1][x][y];
            mass[3][x][y] = mass[0][x][y] | mass[6][x][y];
            mass[4][x][y] = mass[1][x][y] | mass[6][x][y];
            mass[5][x][y] = mass[2][x][y] | mass[6][x][y];
            for (int i = 0; i < 6; i++) nxt[i].emplace_back(mass[i][x][y]);
        }
    }
    for (int i = 0; i < 6; i++) {
        sort(all(nxt[i]));
        nxt[i].erase(unique(all(nxt[i])), end(nxt[i]));
    }
    string S;
    cin >> S;
    int n = S.size();
    vector<map<ull, int>> mp(n + 1);
    auto dfs = [&](auto self, ull cur, int d) -> int {
        if (mp[d].count(cur)) return mp[d][cur];
        assert(d < n);
        int res = 0;
        for (auto &val: nxt[ctoi(S[d])]) {
            if (cur & val) continue;
            if (self(self, cur | val, d + 1) == 0) res = 1;
        }
        return mp[d][cur] = res;
    };
    int ans = dfs(dfs, 0, 0);
    cout << (ans ? "Alice" : "Bob") << "\n";
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3568kb

input:

BBAARRCCQQMM

output:

Bob

result:

ok single line: 'Bob'

Test #2:

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

input:

BAMBAMQQRCCR

output:

Alice

result:

ok single line: 'Alice'

Test #3:

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

input:

QQRAACMRMCBB

output:

Alice

result:

ok single line: 'Alice'

Test #4:

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

input:

MBBARQRMACQC

output:

Alice

result:

ok single line: 'Alice'

Test #5:

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

input:

ACQCMQRBBRMA

output:

Alice

result:

ok single line: 'Alice'

Test #6:

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

input:

MRCMABRQCQAB

output:

Alice

result:

ok single line: 'Alice'

Test #7:

score: -100
Wrong Answer
time: 0ms
memory: 3524kb

input:

BBRCMMQAAQRC

output:

Bob

result:

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