QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#595211 | #5250. Combination Locks | hzy99999# | WA | 0ms | 3664kb | C++20 | 1.8kb | 2024-09-28 13:01:11 | 2024-09-28 13:01:11 |
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;
}
詳細信息
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'