QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#595211#5250. Combination Lockshzy99999#WA 0ms3664kbC++201.8kb2024-09-28 13:01:112024-09-28 13:01:11

Judging History

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

  • [2024-09-28 13:01:11]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3664kb
  • [2024-09-28 13:01:11]
  • 提交

answer

#include <iostream>
#include <cstring>
#include <algorithm>
#include <set>
#include <queue>
using namespace std;
typedef long long LL;
const int N = 1 << 10;
int T;
int n, m;
int f[N]; //, d[N];
string a, b;
bool st[N], v[N];
// void bfs(int u)
// {
//     queue<int> q;
//     q.push(u);
//     while (q.size())
//     {
//         int t = q.front();
//         q.pop();
//         for (int k = 0; k < n; k++)
//         {
//             int x = t ^ (1 << k);
//             if (d[x] || st[x])
//                 continue;
//             d[x] = d[t] + 1;
//             q.push(x);
//         }
//     }
// }
int dfs(int u) // 1A,0B
{
    if (f[u] != -1)
        return f[u];

    set<int> state;
    for (int k = 0; k < n; k++)
    {
        int x = u ^ (1 << k);
        if (v[x] || st[x])
            continue;
        v[x] = 1;
        int t = dfs(x);
        v[x] = 0;
        if (!state.count(t))
            state.insert(t);
    }
    int res = 0;
    while (state.count(res))
        res++;
    return f[u] = res;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> T;
    while (T--)
    {
        cin >> n >> m;
        for (int i = 0; i < 1 << n; i++)
            f[i] = -1, st[i] = v[i] = 0; // d[i] = 0;
        cin >> a >> b;
        int ini = 0;
        for (int i = 0; i < n; i++)
            ini = ini * 2 + (a[i] == b[i]);

        while (m--)
        {
            string temp;
            cin >> temp;
            int x = 0;
            for (int i = 0; i < temp.size(); i++)
                x = x * 2 + (temp[i] == '=');

            st[x] = 1;
        }
        // d[ini] = 1;
        // bfs(ini);
        v[ini] = 1;
        if (dfs(ini))
            cout << "Alice" << endl;
        else
            cout << "Bob" << endl;
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3560kb

input:

2
1 0
0
0
1 1
0
0
.

output:

Alice
Bob

result:

ok 2 lines

Test #2:

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

input:

8
2 0
00
00
2 1
00
00
..
2 1
00
00
=.
2 2
00
00
..
=.
2 1
00
00
.=
2 2
00
00
..
.=
2 2
00
00
=.
.=
2 3
00
00
..
=.
.=

output:

Alice
Alice
Bob
Alice
Bob
Alice
Bob
Bob

result:

ok 8 lines

Test #3:

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

input:

20
4 4
4714
5245
..=.
..==
.==.
==..
4 1
2697
1438
.=..
4 5
9255
0677
...=
..==
=..=
==.=
====
4 12
3292
7326
...=
..=.
..==
.=..
.=.=
.==.
=...
=..=
=.==
==..
==.=
====
4 9
8455
2536
...=
..==
.=..
.=.=
.==.
.===
=...
==..
===.
4 12
5755
1517
...=
..=.
..==
.=..
.=.=
.===
=..=
=.=.
=.==
==..
==.=
=...

output:

Alice
Bob
Alice
Bob
Bob
Alice
Bob
Bob
Alice
Alice
Bob
Alice
Alice
Bob
Bob
Bob
Bob
Bob
Bob
Bob

result:

ok 20 lines

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 3664kb

input:

20
5 30
99942
90170
.....
....=
...==
..=..
..=.=
..==.
..===
.=...
.=..=
.=.=.
.=.==
.==..
.==.=
.===.
.====
=...=
=..=.
=..==
=.=..
=.=.=
=.==.
=.===
==...
==..=
==.=.
==.==
===..
===.=
====.
=====
5 14
11760
95480
...=.
...==
..=..
..=.=
.=...
.=..=
.====
=....
=...=
=.=..
=.==.
==...
==.==
=====...

output:

Bob
Alice
Alice
Alice
Alice
Bob
Bob
Bob
Alice
Alice
Alice
Bob
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Alice

result:

wrong answer 20th lines differ - expected: 'Bob', found: 'Alice'