QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#592659#7635. Fairy ChesswkrWA 9ms3724kbC++142.8kb2024-09-27 01:11:182024-09-27 01:11:19

Judging History

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

  • [2024-09-27 01:11:19]
  • 评测
  • 测评结果:WA
  • 用时:9ms
  • 内存:3724kb
  • [2024-09-27 01:11:18]
  • 提交

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>, 6> hit;
string s;
array<int, 12> a;
inline bool Alice(int nums, ull vis, ull used);
inline bool Bob(int nums, ull vis, ull used);

inline int pos(int x, int y)
{
    return 8 * x + y;
}

inline bool Alice(int nums, ull vis, ull used)
{
    if (nums == 12)
    {
        return 0;
    }
    for (int i = 0; i < 64; i++)
    {
        if ((1ull << i) & used)
        {
            continue;
        }
        ull who = hit[a[nums]][i];
        if (vis & who)
        {
            continue;
        }
        if (Bob(nums + 1, vis | (1ull << i), used | who))
        {
            return 1;
        }
    }
    return 0;
}

inline bool Bob(int nums, ull vis, ull used)
{
    for (int i = 0; i < 64; i++)
    {
        if ((1ull << i) & used)
        {
            continue;
        }
        ull who = hit[a[nums]][i];
        if (vis & who)
        {
            continue;
        }
        if (!Alice(nums + 1, vis | (1ull << i), used | who))
        {
            return 0;
        }
    }
    return 1;
}

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 x = 0; x < 8; x++)
            {
                for (int y = 0; y < 8; y++)
                {
                    int dx = i - x;
                    int dy = j - y;
                    if (dx * dx + dy * dy == 5)
                    {
                        p |= 1ull << pos(x, y);
                    }
                }
            }
            for (int k = 3; k <= 5; k++)
            {
                hit[k][idx] = p | hit[k - 3][idx];
            }
        }
    }
    if (Alice(0, 0, 0))
    {
        cout << "Alice" << endl;
    }
    else
    {
        cout << "Bob" << endl;
    }
}

signed main()
{
    close;
    solved();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 9ms
memory: 3640kb

input:

BBAARRCCQQMM

output:

Bob

result:

ok single line: 'Bob'

Test #2:

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

input:

BAMBAMQQRCCR

output:

Alice

result:

ok single line: 'Alice'

Test #3:

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

input:

QQRAACMRMCBB

output:

Alice

result:

ok single line: 'Alice'

Test #4:

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

input:

MBBARQRMACQC

output:

Alice

result:

ok single line: 'Alice'

Test #5:

score: 0
Accepted
time: 3ms
memory: 3656kb

input:

ACQCMQRBBRMA

output:

Alice

result:

ok single line: 'Alice'

Test #6:

score: -100
Wrong Answer
time: 6ms
memory: 3576kb

input:

MRCMABRQCQAB

output:

Bob

result:

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