QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#228116 | #7635. Fairy Chess | ucup-team133# | WA | 1ms | 3556kb | C++20 | 2.4kb | 2023-10-28 12:15:02 | 2023-10-28 12:15:03 |
Judging History
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 (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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3552kb
input:
BBAARRCCQQMM
output:
Bob
result:
ok single line: 'Bob'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3504kb
input:
BAMBAMQQRCCR
output:
Alice
result:
ok single line: 'Alice'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3428kb
input:
QQRAACMRMCBB
output:
Alice
result:
ok single line: 'Alice'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3416kb
input:
MBBARQRMACQC
output:
Alice
result:
ok single line: 'Alice'
Test #5:
score: 0
Accepted
time: 1ms
memory: 3556kb
input:
ACQCMQRBBRMA
output:
Alice
result:
ok single line: 'Alice'
Test #6:
score: 0
Accepted
time: 1ms
memory: 3484kb
input:
MRCMABRQCQAB
output:
Alice
result:
ok single line: 'Alice'
Test #7:
score: -100
Wrong Answer
time: 1ms
memory: 3548kb
input:
BBRCMMQAAQRC
output:
Bob
result:
wrong answer 1st lines differ - expected: 'Alice', found: 'Bob'