QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#233597 | #7635. Fairy Chess | ucup-team635 | WA | 849ms | 3616kb | C++23 | 2.5kb | 2023-10-31 20:09:36 | 2023-10-31 20:09:36 |
Judging History
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);
}
void run(void) {
auto pos = [](const i32 x, const i32 y) -> i32 {
return x * 8 + y;
};
u64 hit[6][64];
REP(x, 0, 8) {
REP(y, 0, 8) {
u64 a = 0;
REP(i, 0, 8) {
a |= (u64)1 << pos(x, i);
a |= (u64)1 << pos(i, y);
}
u64 b = 0;
REP(i, 0, 8) {
REP(j, 0, 8) {
if (x + y == i + j && x - y == i - j) {
b |= (u64)1 << pos(i, j);
}
}
}
u64 c = 0;
pair<i32, i32> dir = make_pair(1, 2);
REP(i, 0, 2) {
REP(j, 0, 4) {
const i32 p = x + dir.first;
const i32 q = y + dir.second;
if (0 <= p && p < 8 && 0 <= q && q < 8) {
c |= (u64)1 << pos(p, q);
}
dir = make_pair(dir.second, -dir.first);
}
}
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;
}
}
}
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;
}
}
}
auto calc = [&](auto self, const u64 ban, const u64 elem, const i32 k) -> bool {
REP(i, 0, 64) {
if ((ban >> i) & 1) continue;
const u64 mask = hit[a[k]][i];
if (mask & elem) continue;
if (!self(self, ban | mask, elem | ((u64)1 << i), k + 1)) return true;
}
return false;
};
cout << (calc(calc, 0, 0, 0) ? "Alice" : "Bob") << "\n";
}
int main(void) {
cin.tie(nullptr);
ios::sync_with_stdio(false);
run();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 849ms
memory: 3616kb
input:
BBAARRCCQQMM
output:
Bob
result:
ok single line: 'Bob'
Test #2:
score: 0
Accepted
time: 125ms
memory: 3524kb
input:
BAMBAMQQRCCR
output:
Alice
result:
ok single line: 'Alice'
Test #3:
score: -100
Wrong Answer
time: 143ms
memory: 3528kb
input:
QQRAACMRMCBB
output:
Bob
result:
wrong answer 1st lines differ - expected: 'Alice', found: 'Bob'