QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#141458#5250. Combination LocksPhantomThreshold#WA 1ms3516kbC++201.5kb2023-08-17 13:55:392023-08-17 13:55:42

Judging History

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

  • [2023-08-17 13:55:42]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3516kb
  • [2023-08-17 13:55:39]
  • 提交

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'