在 n 道题目中挑选一些使得所有人对题目的掌握情况不超过一半。
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!
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.
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").
5 3
1 0 1
1 1 0
1 0 0
1 0 0
1 0 0
NO
3 2
1 0
1 1
0 1
YES
在 n 道题目中挑选一些使得所有人对题目的掌握情况不超过一半。
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
bool vis[];
int main(){
int n,k,x;
scanf("%d%d",&n,&k);
for(int i=;i<=n;++i) {
int sum=;
for(int j=;j<=k;++j) {
scanf("%d",&x);
if(x) sum+=<<(j-);
}
vis[sum]=;
}
bool flag=;
for(int i=;i<=;++i) for(int j=;j<=;++j) if(((i&j)==)&&vis[i]&&vis[j]) flag=;
if(flag) puts("YES");else puts("NO");
}
最新文章
- iOS系统网络抓包方法
- java打jar包,引用其他.jar文件
- JSP知识
- HDFS
- youku的视频代码放到网站上如何实现自适应
- git分支使用
- 蚂蚁【A001】
- Spring 读书笔记-----使用Spring容器(一)
- C#中判断空字符串的3种方法性能分析
- sql 建立数据库,表格,索引,主键
- 喜大本\\ u0026普,微软的开源
- Java基本数据类型及其封装器的一些千丝万缕的纠葛
- Java经典编程题50道之三十九
- 基于ECharts的饼状数据展示
- IDEA修改显示星号*和热部署
- python learn note1
- 在新安装的Centos中安装python3.7 解决pip和yum问题
- postgres(pgAdmin) 客户端保存密码
- Chrome 不能访问tensorboard解决
- 20145331魏澍琛《网络对抗》Exp5 MSF基础应用