Codeforces 868 C Qualification Rounds

题目链接

题目大意:有n个题目和k个队伍。给出每个队伍对题目的知道与否。问能否从这些题目中选出一些题目,使每个队伍知道的题目数量至多为选题数的一半。

题目分析:很明显如果能选出3个题目来,那一定能在3个题目中选2个题目作为题目集。如果能选出4个题目来,那一定能从中选3个。以此类推,能选2个题目是通解。相反的如果连2个题目都选不出来那就说明不存在这样的题目集。

把每一个题目的状态都压缩然后枚举所有状态就可以了。

#include<iostream>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<algorithm>
#include<queue>
#include<set>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<cmath>
#include<stack>
//#define mod 1030
#define size 3
using namespace std;
typedef long long LL;
const int maxn = 1e5 + 100;
const int maxm = 50000;
const LL inf = (LL)6 * LL(1e18);
const double eps = 1e-8;
int dp[20];
int main() {
	int n, k;
	while (scanf("%d%d", &n, &k) == 2) {
		memset(dp, 0, sizeof(dp));
		int cnt = 0, x;
		for (int i = 1; i <= n; i++) {
			cnt = 0;
			for (int j = 1; j <= k; j++) {
				scanf("%d", &x);
				cnt += (1 << (j - 1))*x;
			}
			dp[cnt] = 1;
		}
		bool flag = false;
		for (int i = 0; i < 16; i++)
			for (int j = 0; j < 16; j++)
				if ((i&j) == 0 && dp[i] && dp[j])
					flag = true;
		printf("%s\n", flag ? "YES" : "NO");
	}
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值