QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#102762#5250. Combination LocksLuken#TL 19ms1876kbC++141.7kb2023-05-03 17:25:262023-05-03 17:25:30

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-03 17:25:30]
  • Judged
  • Verdict: TL
  • Time: 19ms
  • Memory: 1876kb
  • [2023-05-03 17:25:26]
  • Submitted

answer

//
// Created by 86189 on 2023/5/3.
//

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>

#define N 1100
using namespace std;
int two[12] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048};
int bz[N], n, m;
int a[N], b[N];
char s[N];

void input() {
    int len = 0;
    char c = getchar();
    while (c < '0' || c > '9')c = getchar();
    while (c >= '0' && c <= '9') {
        s[++len] = c;
        c = getchar();
    }
}

void inp() {
    int len = 0;
    char c = getchar();
    while (c != '=' && c != '.')c = getchar();
    while (c == '=' || c == '.') {
        s[++len] = c;
        c = getchar();
    }
}

bool dfs(int ch, int sta) {
    int o = 0;
    for (int i = 0; i < n; i++) {
        int p = sta ^ two[i];
        if (bz[p])continue;
        o = 1;
        bz[p]=1;
        bool b = dfs(ch ^ 1, p);
        bz[p]=0;
        if (!b)return true;
    }
    return false;
}

int main() {
    int T;
    scanf("%d", &T);
    while (T--) {
        memset(bz, 0, sizeof(bz));
        scanf("%d%d", &n, &m);
        int ini = 0;
        input();
        for (int i = 1; i <= n; i++)a[i] = s[i] - '0';
        input();
        for (int i = 1; i <= n; i++)b[i] = s[i] - '0';
        for (int i = 1; i <= n; i++) {
            if (a[i] == b[i])
                ini ^= two[i - 1];
        }
        bz[ini]=1;
        for (int i = 1; i <= m; i++) {
            inp();
            int t = 0;
            for (int j = 1; j <= n; j++) {
                if (s[j] == '=')t ^= two[j - 1];
            }
            bz[t] = 1;
        }
        bool ans = dfs(1, ini);
        if(!ans)printf("Bob\n");
        else printf("Alice\n");
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 1508kb

input:

2
1 0
0
0
1 1
0
0
.

output:

Alice
Bob

result:

ok 2 lines

Test #2:

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

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: 1ms
memory: 1748kb

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: 0
Accepted
time: 19ms
memory: 1612kb

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
Bob

result:

ok 20 lines

Test #5:

score: -100
Time Limit Exceeded

input:

20
6 62
188256
588825
......
.....=
....=.
....==
...=..
...=.=
...==.
...===
..=...
..=..=
..=.=.
..=.==
..==..
..==.=
..===.
..====
.=....
.=...=
.=..=.
.=..==
.=.=..
.=.=.=
.=.==.
.=.===
.==..=
.==.=.
.==.==
.===..
.===.=
.=====
=.....
=....=
=...=.
=...==
=..=..
=..=.=
=..==.
=..===
=.=...
=.=.....

output:


result: