QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#141458 | #5250. Combination Locks | PhantomThreshold# | WA | 1ms | 3516kb | C++20 | 1.5kb | 2023-08-17 13:55:39 | 2023-08-17 13:55:42 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
int T;
cin>>T;
while(T--)
{
int n,c;
cin>>n>>c;
string s,t;
cin>>s>>t;
s=s;t=t;
int now=0;
for(int i=0;i<n;i++)
{
if(s[i]==t[i])
now|=(1<<i);
}
vector<int> mark(1<<n);
for(int i=1;i<=c;i++)
{
cin>>s;
int t=0;
for(int j=0;j<n;j++)
{
if(s[j]=='=')
t|=(1<<j);
}
mark[t]=1;
}
vector<vector<int>> G(1<<n);
int tot=0;
for(int i=0;i<(1<<n);i++)
{
if(mark[i])continue;
tot++;
for(int j=0;j<n;j++)
{
if(not mark[i] and not mark[i^(1<<j)])
{
G[i].push_back(i^(1<<j));
}
}
}
vector<int> ma(1<<n),vis(1<<n);
function<bool(int)> dfs=[&](int u)
{
vis[u]=1;
for(auto v:G[u])
{
if(not ma[v])
{
ma[v]=u;
ma[u]=v;
return true;
}
else if(not vis[v])
{
vis[v]=1;
vis[ma[v]]=1;
if(dfs(ma[v]))
{
ma[v]=u;
ma[u]=v;
return true;
}
}
}
return false;
};
for(int i=0;i<(1<<n);i++)
{
if(mark[i])continue;
if(__builtin_parity(now)==__builtin_parity(i))
{
fill(vis.begin(),vis.end(),0);
dfs(i);
}
}
fill(vis.begin(),vis.end(),0);
for(int i=0;i<(1<<n);i++)
{
if(mark[i])continue;
if(__builtin_parity(now)==__builtin_parity(i) and not ma[i])
{
dfs(i);
}
}
if(ma[now] and not vis[now])cout<<"Alice\n";
else cout<<"Bob\n";
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3516kb
input:
2 1 0 0 0 1 1 0 0 .
output:
Bob Bob
result:
wrong answer 1st lines differ - expected: 'Alice', found: 'Bob'