QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#180953 | #5250. Combination Locks | ucup-team1209# | WA | 1ms | 3620kb | C++20 | 1.8kb | 2023-09-16 14:38:35 | 2023-09-16 14:38:36 |
Judging History
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];
bool ban[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);
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;
}
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;
}
}
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;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3548kb
input:
2 1 0 0 0 1 1 0 0 .
output:
Alice Bob
result:
ok 2 lines
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3620kb
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 Alice Alice Bob Bob Bob Bob
result:
wrong answer 3rd lines differ - expected: 'Bob', found: 'Alice'