QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#227581 | #7635. Fairy Chess | ucup-team1447# | WA | 1ms | 3688kb | C++14 | 2.2kb | 2023-10-27 19:03:16 | 2023-10-27 19:03:17 |
Judging History
answer
// This Code was made by Chinese_zjc_.
#include <bits/stdc++.h>
using ull = unsigned long long;
std::map<ull, bool> dp[12];
std::string s;
ull B[64], R[64], K[64], Q[64], A[64], C[64], M[64];
int id(int x, int y) { return x << 3 | y; }
ull g(int pos, char type)
{
switch (type)
{
case 'B':
return B[pos];
case 'R':
return R[pos];
case 'Q':
return Q[pos];
case 'A':
return A[pos];
case 'C':
return C[pos];
case 'M':
return M[pos];
default:
return K[pos];
}
}
bool dfs(ull x, int y)
{
if (!~x)
return false;
bool res = dp[y][x];
for (int i = 0; i != 64; ++i)
if (!(x & g(i, s[y])))
res |= !dfs(x | g(i, s[y]), y + 1);
return res;
}
signed main()
{
std::ios::sync_with_stdio(false);
for (int i = 0; i != 8; ++i)
for (int j = 0; j != 8; ++j)
{
for (int k = -8; k != 8; ++k)
{
if (i + k >= 0 && j + k >= 0 && i + k < 8 && j + k < 8)
B[id(i, j)] |= 1llu << id(i + k, j + k);
if (i + k >= 0 && j - k >= 0 && i + k < 8 && j - k < 8)
B[id(i, j)] |= 1llu << id(i + k, j - k);
}
for (int k = -8; k != 8; ++k)
{
if (i + k >= 0 && j >= 0 && i + k < 8 && j < 8)
R[id(i, j)] |= 1llu << id(i + k, j);
if (i >= 0 && j + k >= 0 && i < 8 && j + k < 8)
R[id(i, j)] |= 1llu << id(i, j + k);
}
for (int iv = -2; iv <= 2; ++iv)
for (int jv = -2; jv <= 2; ++jv)
if (std::abs(iv) + std::abs(jv) == 3 && i + iv >= 0 && j + jv >= 0 && i + iv < 8 && j + jv < 8)
K[id(i, j)] |= 1llu << id(i + iv, j + jv);
K[id(i, j)] |= 1llu << id(i, j);
Q[id(i, j)] = B[id(i, j)] | R[id(i, j)];
A[id(i, j)] = B[id(i, j)] | K[id(i, j)];
C[id(i, j)] = R[id(i, j)] | K[id(i, j)];
M[id(i, j)] = B[id(i, j)] | R[id(i, j)] | K[id(i, j)];
}
std::cin >> s;
std::cout << (dfs(0, 0) ? "Alice" : "Bob") << std::endl;
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3684kb
input:
BBAARRCCQQMM
output:
Bob
result:
ok single line: 'Bob'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3652kb
input:
BAMBAMQQRCCR
output:
Alice
result:
ok single line: 'Alice'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
QQRAACMRMCBB
output:
Alice
result:
ok single line: 'Alice'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
MBBARQRMACQC
output:
Alice
result:
ok single line: 'Alice'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
ACQCMQRBBRMA
output:
Alice
result:
ok single line: 'Alice'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
MRCMABRQCQAB
output:
Alice
result:
ok single line: 'Alice'
Test #7:
score: -100
Wrong Answer
time: 1ms
memory: 3688kb
input:
BBRCMMQAAQRC
output:
Bob
result:
wrong answer 1st lines differ - expected: 'Alice', found: 'Bob'