QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#592594 | #7635. Fairy Chess | wkr | WA | 11ms | 3720kb | C++14 | 2.4kb | 2024-09-27 00:20:02 | 2024-09-27 00:20:03 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define close ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
typedef unsigned long long ull;
const string t = "RBQACM";
array<array<ull, 64>, 8> hit;
string s;
array<int, 12> a;
inline int pos(int x, int y)
{
return 8 * x + y;
}
int cnt = 0;
inline bool dfs(int nums, ull vis, ull used)
{
for (int i = 0; i < 64; i++)
{
if ((used >> i) & 1)
{
continue;
}
ull who = hit[a[nums]][i];
if (vis & who)
{
continue;
}
cnt = max(cnt, nums + 1);
if (!dfs(nums + 1, vis | (1ull << i), used | who))
{
return 1;
}
}
return 0;
}
void solved()
{
cin >> s;
for (int i = 0; i < 12; i++)
{
a[i] = t.find(s[i]);
}
for (int i = 0; i < 8; i++)
{
for (int j = 0; j < 8; j++)
{
ull p = 0;
int idx = pos(i, j);
for (int k = 0; k < 8; k++)
{
hit[0][idx] |= 1ull << pos(i, k);
hit[0][idx] |= 1ull << pos(k, j);
}
for (int x = 0; x < 8; x++)
{
for (int y = 0; y < 8; y++)
{
if (x + y == i + j || x - y == i - j)
{
hit[1][idx] |= 1ull << pos(x, y);
}
}
}
hit[2][idx] = hit[0][idx] | hit[1][idx];
for (int dx = -2; dx <= 2; dx++)
{
for (int dy = -2; dy <= 2; dy++)
{
if (dx * dx + dy * dy == 5)
{
int x = i + dx;
int y = j + dy;
if (0 <= x && x < 8 && 0 <= y && y < 8)
{
p |= 1ull << pos(x, y);
}
}
}
}
for (int k = 3; k <= 5; k++)
{
hit[k][pos(i, j)] = p | hit[k - 3][pos(i, j)];
}
}
}
dfs(0, 0, 0);
if (cnt%2==1)
{
cout << "Alice" << endl;
}
else
{
cout << "Bob" << endl;
}
}
signed main()
{
close;
solved();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 11ms
memory: 3720kb
input:
BBAARRCCQQMM
output:
Bob
result:
ok single line: 'Bob'
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3652kb
input:
BAMBAMQQRCCR
output:
Bob
result:
wrong answer 1st lines differ - expected: 'Alice', found: 'Bob'