QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#597060 | #5250. Combination Locks | hzy99999# | WA | 0ms | 3568kb | C++20 | 1.8kb | 2024-09-28 16:58:50 | 2024-09-28 16:58:50 |
Judging History
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: 3492kb
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: 3500kb
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: 3508kb
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: 0ms
memory: 3568kb
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
Wrong Answer
time: 0ms
memory: 3508kb
input:
20 6 62 188256 588825 ...... .....= ....=. ....== ...=.. ...=.= ...==. ...=== ..=... ..=..= ..=.=. ..=.== ..==.. ..==.= ..===. ..==== .=.... .=...= .=..=. .=..== .=.=.. .=.=.= .=.==. .=.=== .==..= .==.=. .==.== .===.. .===.= .===== =..... =....= =...=. =...== =..=.. =..=.= =..==. =..=== =.=... =.=.....
output:
Bob Bob Alice Alice Alice Bob Bob Bob Alice Bob Bob Bob Alice Alice Alice Bob Alice Alice Alice Alice
result:
wrong answer 9th lines differ - expected: 'Bob', found: 'Alice'