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!

题目大意:

有n个为题,每个问题被一些球队知道,现能否选出一些问题,使得每个队知道的问题至多一半

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
Input
5 3
1 0 1
1 1 0
1 0 0
1 0 0
1 0 0
Output
NO
Input
3 2
1 0
1 1
0 1
Output
YES
Note

In the first example you can't make any interesting problemset, because the first team knows all problems.

In the second example you can choose the first and the third problems.

ZYYS(贼有意思)

首先经分析发现,最好情况下只要2个就行了

因为假如选了2个不符条件,选了3个符合条件,那么显然可以只选其中2个

如果只选2个解决不了,那么显然多选也解决不了

把每一个问题的状态压缩,枚举所有状态,如果(i&j)==0那么就可以

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int f[],n,k,flag;
int main()
{int i,j,x;
cin>>n>>k;
for (i=;i<=n;i++)
{
int cnt=;
for (j=;j<=k;j++)
{
scanf("%d",&x);
cnt+=(<<j-)*x;
}
f[cnt]=;
}
flag=;
for (i=;i<;i++)
for (j=;j<;j++)
if ((i&j)==&&f[i]&&f[j])
{
flag=;
}
if (flag) cout<<"YES\n";
else cout<<"NO\n";
}

codeforces 868C Qualification Rounds的更多相关文章

  1. [Codeforces Round #438][Codeforces 868C. Qualification Rounds]

    题目链接:868C - Qualification Rounds 题目大意:有\(n\)个题目,\(k\)个人,每个人可能做过这\(n\)个题里的若干道,出题方要在这\(n\)个题目里选若干个出来作为 ...

  2. Codeforces 868C Qualification Rounds - 位运算

    Snark and Philip are preparing the problemset for the upcoming pre-qualification round for semi-quar ...

  3. codeforces 868C - Qualification Rounds(构造)

    原题链接:http://codeforces.com/problemset/problem/868/C 题意:有k个队伍参加比赛,比赛有n个预选的题目,有些队伍对已经事先知道了一些题目.问能不能选出若 ...

  4. 【Codeforces】868C. Qualification Rounds

    [题目]C. Qualification Rounds [题意]给定n个问题和K个人,给定每个人知道的问题列表,求能否找到一个非空问题集合,满足每个人知道的集合中问题数量都不超过集合总题数的一半.n& ...

  5. F - Qualification Rounds CodeForces - 868C 二进制

    F - Qualification Rounds CodeForces - 868C 这个题目不会,上网查了一下,发现一个结论就是如果是可以的,那么两个肯定可以满足. 然后就用二进制来压一下这个状态就 ...

  6. Codeforces Round #438 C - Qualification Rounds 思维

    C. Qualification Rounds time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  7. codeforces 868C

    C. Qualification Rounds time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  8. Codeforces Round #438 C. Qualification Rounds

    Description Snark and Philip are preparing the problemset for the upcoming pre-qualification round f ...

  9. 【Codeforces Round #438 C】 Qualification Rounds

    [链接]h在这里写链接 [题意] 给你n个问题,每个人都知道一些问题. 然后让你选择一些问题,使得每个人知道的问题的数量,不超过这些问题的数量的一半. [题解] 想法题. 只要有两个问题. 这两个问题 ...

随机推荐

  1. C语言第三次博客作业

    一.PTA实验作业 1 1.实验代码 int i,N; char sex; float high; scanf("%d",&N); for(i =1;i <=N;i ...

  2. 20155306 2006-2007-2 《Java程序设计》第3周学习总结

    20155306 2006-2007-2 <Java程序设计>第3周学习总结 教材学习内容总结 第四章 认识对象 4.1 类与对象 定义类 1.先在程序中定义类: Clothes{ Str ...

  3. 20162317袁逸灏 第八周实验报告:实验二 Java面向对象程序设计

    20162317袁逸灏 第八周实验报告:实验二 Java面向对象程序设计 实验内容 初步掌握单元测试和TDD 理解并掌握面向对象三要素:封装.继承.多态 初步掌握UML建模 熟悉S.O.L.I.D原则 ...

  4. Java 密码学算法

    Java 密码学算法 候捷老师在< 深入浅出MFC 2e(电子版)>中引用林语堂先生的一句话: 只用一样东西,不明白它的道理,实在不高明 只知道How,不知道Why,出了一点小问题时就无能 ...

  5. 201621123031 《Java程序设计》第11周学习总结

    作业11-多线程 1. 本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结多线程相关内容. 2. 书面作业 本次PTA作业题集多线程 1. 源代码阅读:多线程程序BounceThread ...

  6. fs输出文件目录

    var http = require("http"); var fs = require("fs"); var server = http.createServ ...

  7. 【iOS】swift-文字宽度的计算

    如图所示,需要sectionView的标题宽度可以动态变化 举例说明: 只需在tableView的代理方法 func tableView(tableView: UITableView, viewFor ...

  8. Spark学习笔记之RDD中的Transformation和Action函数

    总算可以开始写第一篇技术博客了,就从学习Spark开始吧.之前阅读了很多关于Spark的文章,对Spark的工作机制及编程模型有了一定了解,下面把Spark中对RDD的常用操作函数做一下总结,以pys ...

  9. 关于团购VPS的事情报告

    作者 玄魂   2017-08-11 玄魂工作室-玄魂 玄魂工作室首先要抱歉,之前的说的继续组织大家购买vps的事情,不会再组织了.原因有以下几个:1)因为人多,需求各不相同,不好协调.2)服务都是购 ...

  10. python入门:python包管理工具pip的安装

    pip 是一个安装和管理 Python 包的工具 , 是 easy_install 的一个替换品. distribute是setuptools的取代(Setuptools包后期不再维护了),pip是e ...