Codeforces Round #438 C. Qualification Rounds
来源:互联网 发布:淘宝十元包邮专区在哪 编辑:程序博客网 时间:2024/05/16 08:02
$###Description
Snark and Philip are preparing the problemset for the upcoming pre-qualification round for semi-quarter-finals. They have a bank of n problems, and they want to select any non-empty subset of it as a problemset.
k experienced teams are participating in the contest. Some of these teams already know some of the problems. To make the contest interesting for them, each of the teams should know at most half of the selected problems.
Determine if Snark and Philip can make an interesting problemset!
Input
The first line contains two integers n, k (1 ≤ n ≤ 105, 1 ≤ k ≤ 4) — the number of problems and the number of experienced teams.
Each of the next n lines contains k integers, each equal to 0 or 1. The j-th number in the i-th line is 1 if j-th team knows i-th problem and 0 otherwise.
Output
Print “YES” (quotes for clarity), if it is possible to make an interesting problemset, and “NO” otherwise.
You can print each character either upper- or lowercase (“YeS” and “yes” are valid when the answer is “YES”).
Examples
input5 31 0 11 1 01 0 01 0 01 0 0outputNOinput3 21 01 10 1outputYES
题目大意
有n个试题,k个队,1代表该对已经知道该题内容,0代表不知道。问从n个试题中任意抽取一部分,是否可以满足每个队最多只能知道不超过一半的试题。
解题思路
将每个队对于每份试题的了解情况看成一种状态转化为二进制,用整数保存并标记出现次数。然后在
代码实现
#include <iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<cmath>#include<vector>using namespace std;#define maxn 16int a[maxn];int main(){ int n,k; int t,mi,z; while(~scanf("%d %d",&n,&k)) { memset(a,0,sizeof(a)); for(int i=0; i<n; i++) { t=0,mi=1<<(k-1); for(int j=0; j<k; j++) { scanf("%d",&z); t+=z*mi; mi/=2; } a[t]++; } bool flag=false; for(int i=0; i<(1<<k); i++) { if(a[i]!=0) { for(int j=0; j<(1<<k); j++) { if(a[j]!=0&&((i&j)==0)) { flag=true; printf("YES\n"); break; } } } if(flag) break; } if(!flag) printf("NO\n"); } return 0;}
- Codeforces Round #438 C. Qualification Rounds
- Codeforces Round #438 C. Qualification Rounds 二进制
- codeforces round #438 C. Qualification Rounds
- Codeforces Round #438 C. Qualification Rounds 题解
- Codeforces Round #438 C. Qualification Rounds
- Codeforces Round #438 C Qualification Rounds(暴力+位运算)
- Codeforces Round #438 C 868C Qualification Rounds(思维,非状压dp)
- Codeforces 868 C Qualification Rounds
- codeforces 868C Qualification Rounds
- Codeforces round438 C. Qualification Rounds
- codeforces 868C Qualification Rounds
- Codeforces 868C Qualification Rounds
- Codeforces 868C Qualification Rounds
- CodeForces 868C Qualification Rounds
- codeforces 868C Qualification Rounds
- Codeforces Round #438 (Div. 1 + Div. 2 combined) C. Qualification Rounds
- 【状态压缩 && 思维转换】Codeforces Round #438 868C Qualification Rounds
- Codeforces Round #438 C.Qualification Rounds(状态压缩再枚举状态)
- mybatis报错:java.lang.IllegalArgumentException: Mapped Statements collection does not contain
- 【Halcon教程6】halcon/c++接口基础 之异常处理
- hdu 4734(数位dp)
- java之字符串
- HDU 6183 Color it 线段树(动态分配节点)
- Codeforces Round #438 C. Qualification Rounds
- HDOJ2064汉诺塔III
- mysql安装未设置密码 使用root账户登录报错
- 这六个理由告诉你学Java到底有多好!
- 【Halcon教程7】 halcon/c++接口基础 之 HALCON图像变量类
- Java常见异常总结
- mt7601的ap驱动在s5pv210开发板上的编译,装载及配置使用
- BZOJ 2292 【POJ Challenge 】永远挑战 dijkstra
- 【NOIP2017提高A组模拟10.5】Ping