QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#180960#5250. Combination Locksucup-team1209#AC ✓69ms3796kbC++201.9kb2023-09-16 14:43:502023-09-16 14:43:51

Judging History

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

  • [2023-09-16 14:43:51]
  • 评测
  • 测评结果:AC
  • 用时:69ms
  • 内存:3796kb
  • [2023-09-16 14:43:50]
  • 提交

answer

#include <bits/stdc++.h>
#define cs const
#define pb push_back
using namespace std;
using pi = pair <int, int> ; 
using ll = long long;
cs int N = 1050;  

int T, n, C;  
char a[N], b[N];

using Set = bitset <N> ; 
Set edge [N];

bool dfs(int x, Set & unvis, vector <int> & match) {
    for(Set z = edge[x]; ; ) {
        z &= unvis; 
        int y = z._Find_first();
        if(y == N) return 0; 
        if(unvis.reset(y), !match[y] || dfs(match[y], unvis, match)) {
            return match[y] = x, 1; 
        }
    }
}
int match (int nl, int nr) {
    Set unvis; 
    unvis.set();
    vector <int> match(nr + 1), ret(nl + 1);
    int ans = 0; 
    for(int i = 1; i <= nl; i++) 
        if(dfs(i, unvis, match))
            unvis.set(), ++ ans; 
    return ans; 
}


void Main() {
    scanf("%d%d", &n, &C);
    scanf("%s%s", a, b);
    vector <int> ban(1 << n);
    int S = 0; 
    for(int i = 0; i < n; i++) 
        S = S << 1 | (a[i] == b[i]);
    for(int i = 0; i < C; i++) {
        int x = 0; 
        scanf("%s", a);
        for(int j = 0; j < n; j++) 
            x = x << 1 | (a[j] == '=');
        ban[x] = 1; 
    }
    // cout << S <<endl;
    for(int i = 0; i < (1 << n); i++) 
    if(!ban[i] && (__builtin_popcount(i) & 1)) {
        for(int j = 0; j < n; j++) {
            int v = i ^ (1 << j);
            if(!ban[v]) edge[i][v] = 1;//, cout << i << ' ' <<  v<< endl; 
        }
    }
    int cnt = match(1 << n, 1 << n);
    for(int j = 0; j < n; j++) {
        int v = S ^ (1 << j);
        edge[v][S] = edge[S][v] = 0; 
    }
    int cnt2 = match(1 << n, 1 << n);
    if(cnt == cnt2) {
        puts("Bob");
    }
    else {
        puts("Alice");
    }
    for(int i = 0; i < (1 << n); i++) 
        edge[i].reset();
}



int main() {
    #ifdef zqj
    freopen("1.in","r",stdin);
    #endif

    cin >> T; 
    while(T--) Main();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 3560kb

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: 3608kb

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

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: 0
Accepted
time: 1ms
memory: 3576kb

input:

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

output:

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

result:

ok 20 lines

Test #6:

score: 0
Accepted
time: 2ms
memory: 3632kb

input:

20
7 34
1829551
8802318
....=.=
...=.==
...===.
..=..=.
..=..==
..=.==.
.=...==
.=..===
.=.=.=.
.=.==..
.==....
.==...=
.==.=.=
.==.===
.===.==
=.....=
=..=.=.
=..=.==
=..==..
=..==.=
=.=.=..
=.=.=.=
=.==..=
=.==.=.
=.===..
=.===.=
=.=====
==.....
==..===
==.==.=
===....
===..==
====.==
=====.=
7 56...

output:

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

result:

ok 20 lines

Test #7:

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

input:

20
8 101
98515990
35971617
......==
....==..
....==.=
...=.=..
...=.=.=
...=.==.
...==...
...==.==
...===..
...===.=
...====.
..=..=..
..=..==.
..=.=..=
..=.=.==
..=.==.=
..=.===.
..==...=
..==..==
..==.=..
..==.=.=
..===..=
.=...=..
.=...=.=
.=...===
.=..=...
.=..=..=
.=..==.=
.=..===.
.=..====
.=....

output:

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

result:

ok 20 lines

Test #8:

score: 0
Accepted
time: 12ms
memory: 3632kb

input:

20
9 280
799210637
072013670
.........
......=.=
......==.
.....=...
.....=..=
.....=.=.
.....===.
.....====
....=....
....=.==.
....==...
....==..=
....==.==
....=====
...=.....
...=....=
...=...==
...=..=..
...=..=.=
...=..==.
...=.=...
...=.=..=
...=.=.=.
...=.=.==
...=.==.=
...=.====
...==..=.
....

output:

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

result:

ok 20 lines

Test #9:

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

input:

20
3 0
000
000
3 1
000
000
...
3 1
000
000
=..
3 2
000
000
...
=..
3 1
000
000
.=.
3 2
000
000
...
.=.
3 2
000
000
=..
.=.
3 3
000
000
...
=..
.=.
3 1
000
000
==.
3 2
000
000
...
==.
3 2
000
000
=..
==.
3 3
000
000
...
=..
==.
3 2
000
000
.=.
==.
3 3
000
000
...
.=.
==.
3 3
000
000
=..
.=.
==.
3 4
0...

output:

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

result:

ok 20 lines

Test #10:

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

input:

20
3 2
000
000
.=.
..=
3 3
000
000
...
.=.
..=
3 3
000
000
=..
.=.
..=
3 4
000
000
...
=..
.=.
..=
3 2
000
000
==.
..=
3 3
000
000
...
==.
..=
3 3
000
000
=..
==.
..=
3 4
000
000
...
=..
==.
..=
3 3
000
000
.=.
==.
..=
3 4
000
000
...
.=.
==.
..=
3 4
000
000
=..
.=.
==.
..=
3 5
000
000
...
=..
.=.
=...

output:

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

result:

ok 20 lines

Test #11:

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

input:

20
3 2
000
000
==.
=.=
3 3
000
000
...
==.
=.=
3 3
000
000
=..
==.
=.=
3 4
000
000
...
=..
==.
=.=
3 3
000
000
.=.
==.
=.=
3 4
000
000
...
.=.
==.
=.=
3 4
000
000
=..
.=.
==.
=.=
3 5
000
000
...
=..
.=.
==.
=.=
3 2
000
000
..=
=.=
3 3
000
000
...
..=
=.=
3 3
000
000
=..
..=
=.=
3 4
000
000
...
=..
....

output:

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

result:

ok 20 lines

Test #12:

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

input:

20
3 4
000
000
.=.
==.
..=
=.=
3 5
000
000
...
.=.
==.
..=
=.=
3 5
000
000
=..
.=.
==.
..=
=.=
3 6
000
000
...
=..
.=.
==.
..=
=.=
3 1
000
000
.==
3 2
000
000
...
.==
3 2
000
000
=..
.==
3 3
000
000
...
=..
.==
3 2
000
000
.=.
.==
3 3
000
000
...
.=.
.==
3 3
000
000
=..
.=.
.==
3 4
000
000
...
=..
....

output:

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

result:

ok 20 lines

Test #13:

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

input:

20
3 2
000
000
..=
.==
3 3
000
000
...
..=
.==
3 3
000
000
=..
..=
.==
3 4
000
000
...
=..
..=
.==
3 3
000
000
.=.
..=
.==
3 4
000
000
...
.=.
..=
.==
3 4
000
000
=..
.=.
..=
.==
3 5
000
000
...
=..
.=.
..=
.==
3 3
000
000
==.
..=
.==
3 4
000
000
...
==.
..=
.==
3 4
000
000
=..
==.
..=
.==
3 5
000
0...

output:

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

result:

ok 20 lines

Test #14:

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

input:

20
3 3
000
000
.=.
=.=
.==
3 4
000
000
...
.=.
=.=
.==
3 4
000
000
=..
.=.
=.=
.==
3 5
000
000
...
=..
.=.
=.=
.==
3 3
000
000
==.
=.=
.==
3 4
000
000
...
==.
=.=
.==
3 4
000
000
=..
==.
=.=
.==
3 5
000
000
...
=..
==.
=.=
.==
3 4
000
000
.=.
==.
=.=
.==
3 5
000
000
...
.=.
==.
=.=
.==
3 5
000
000
=...

output:

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

result:

ok 20 lines

Test #15:

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

input:

8
3 4
000
000
==.
..=
=.=
.==
3 5
000
000
...
==.
..=
=.=
.==
3 5
000
000
=..
==.
..=
=.=
.==
3 6
000
000
...
=..
==.
..=
=.=
.==
3 5
000
000
.=.
==.
..=
=.=
.==
3 6
000
000
...
.=.
==.
..=
=.=
.==
3 6
000
000
=..
.=.
==.
..=
=.=
.==
3 7
000
000
...
=..
.=.
==.
..=
=.=
.==

output:

Bob
Bob
Bob
Bob
Bob
Bob
Bob
Bob

result:

ok 8 lines

Test #16:

score: 0
Accepted
time: 30ms
memory: 3796kb

input:

20
10 815
4819325421
9470583705
.........=
........=.
.......=..
.......=.=
.......==.
.......===
......=...
......=..=
......=.=.
......=.==
......==..
......===.
......====
.....=....
.....=..==
.....=.=..
.....==...
.....==..=
.....==.=.
.....==.==
.....===..
.....===.=
.....====.
.....=====
.......

output:

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

result:

ok 20 lines

Test #17:

score: 0
Accepted
time: 69ms
memory: 3780kb

input:

20
10 7
9410870639
8237933369
.....=.=.=
...==.==..
..===....=
=..==..=.=
=..==.=.==
=.====.=.=
====.===.=
10 285
0225666838
4493031931
..........
.......=..
.......===
......==..
......==.=
......===.
.....=.=..
.....=.===
.....==...
.....==.==
.....===..
....=...=.
....=..===
....=.=...
....=.=..=...

output:

Bob
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Bob

result:

ok 20 lines