C. Qualification Rounds
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Snark and Philip are preparing the problemset for the upcoming pre-qualification round for semi-quarter-finals. They have a bank of nproblems, 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 nk (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.

题意:现在有k支队伍要参加一个比赛,题库中有n道题目,其中有些队伍已经知道了某些题目,现在给出每道题目每支队伍是否知道的情况,问是否存在一套题目使得所有队伍最多只知道一半的题目。

思路:若有解,则至少有两套题目满足条件,我们只需找到两套题对所有人均满足条件即可。将每套题的状态,用二进制位保存成数字,当两个数字与运算为0则满足条件。

代码:

 #include<bits/stdc++.h>
#define db double
#define ll long long
#define vec vector<ll>
#define Mt vector<vec>
#define ci(x) scanf("%d",&x)
#define cd(x) scanf("%lf",&x)
#define cl(x) scanf("%lld",&x)
#define pi(x) printf("%d\n",x)
#define pd(x) printf("%f\n",x)
#define pl(x) printf("%lld\n",x)
#define rep(i, x, y) for(int i=x;i<=y;i++)
const int N = 1e6 + ;
const int mod = 1e9 + ;
const int MOD = mod - ;
const db eps = 1e-;
const db PI = acos(-1.0);
using namespace std; int n,k;
int ans=;
int s[];
bool v[];
int main()
{
cin>>n>>k;
for(int i=;i<n;i++)
{
int ans=;
for(int j=;j<k;j++){
int x;ci(x);
ans+=(<<j)*x;//二进制保存
}
v[ans]=;
}
for(int i=;i<;i++){
for(int j=;j<;j++){
if(v[i]&&v[j]&&!(i&j)) return *puts("YES");//存在与运算为0的情况
}
}
puts("NO");
}
 

Codeforces Round #438 C - Qualification Rounds 思维的更多相关文章

  1. Codeforces Round #438 C. Qualification Rounds

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

  2. Codeforces Round #438 (Div.1+Div.2) 总结

    本来兴致勃勃的想乘着这一次上紫,于是很早很早的到了机房 但是好像并没有什么用,反而rating-=47 Codeforces Round #438(Div.1+Div.2) 今天就这样匆匆的总结一下, ...

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

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

  4. Codeforces Round #438 by Sberbank and Barcelona Bootcamp (Div. 1 + Div. 2 combined)

    A. Bark to Unlock 题目链接:http://codeforces.com/contest/868/problem/A 题目意思:密码是两个字符组成的,现在你有n个由两个字符组成的字符串 ...

  5. Codeforces Round #438 by Sberbank and Barcelona Bootcamp (Div. 1 + Div. 2 combine

    最近只想喊666,因为我是真得菜,大晚上到网吧打代码还是很不错的嘛 A. Bark to Unlock time limit per test 2 seconds memory limit per t ...

  6. 【Codeforces Round 438 A B C D 四个题】

    题目所在比赛的地址在这里呀 A. Bark to Unlock ·述大意:       输入一个目标串.然后输入n(1<=n<=100)个串,询问是否可以通过这些串收尾相接或者它本身拼出目 ...

  7. Educational Codeforces Round 40 C. Matrix Walk( 思维)

    Educational Codeforces Round 40 (Rated for Div. 2) C. Matrix Walk time limit per test 1 second memor ...

  8. 【Codeforces Round #438 C】 Qualification Rounds

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

  9. Qualification Rounds(Codeforces Round #438 by Sberbank and Barcelona Bootcamp (Div. 1 + Div. 2 combined)+状态压缩)

    题目链接 传送门 题意 现总共有\(n\)个题目\(k\)支参赛队伍,已知每个题目各队伍是否会写,现问你能否从题目中选出一个子序列使得每支队伍最多只会写一半的题目. 思路 对于每个题目我们用二进制压缩 ...

随机推荐

  1. 使用min-content实现容器宽度自适应于内部元素

    前言 设计师可以分为如下两类: 先做好设计,然后将内容放入静态框架中 优秀的设计师充分考虑内容的各个方面及其上下文,并创建适合于内容的设计 HTML原生就是响应式的(HTML内容在视口内流式的分布). ...

  2. vue-2.4.0-添加的新东东

    组件内新增实现属性继承 VUE中一个比较令人烦恼的事情是属性只能从父组件传递给子组件.这也就意味着当你想向嵌套层级比较深组件数据传递,只能由父组件传递给子组件,子组件再传递给孙子组件...像下面这样 ...

  3. Linux 学习 之 bash

    Anything is programmable with defined syntax and common lib. Bash Shell is created to programme to L ...

  4. Linux 两组信号对比

    博客逐步迁移到,独立博客,原文地址 http://www.woniubi.cn/two_groups_signal_difference/ 之前看信号的时候,没有太注意不同信号的对比.今天再次看到的时 ...

  5. 《ArcGIS Runtime SDK for Android开发笔记》——(2)、Android Studio基本配置与使用

    1.前言 在上一篇文章<Android Studio下载与安装>里我们已经介绍了Android Studio的下载与安装步骤,这一篇我们将针对Android Studio的基本常见使用做一 ...

  6. SharePoint 2010 究竟需要占用多少服务器资源?

    SharePoint 安装目录(即SharePoint Root)大约 300M 磁盘空间. SharePoint Config 数据库,60M. Admin Center 数据库,100M. 默认安 ...

  7. AOP术语分析

    初看这么多术语,一下子都不好接受,慢慢来,很快就会搞懂. 通知.增强处理(Advice) 就是你想要的功能,也就是上说的安全.事物.日子等.你给先定义好,然后再想用的地方用一下.包含Aspect的一段 ...

  8. Excel公式巧用-将新值替换旧值,新值为空保留原值

    使用excel时候遇到 将新值替换旧值,新值为空保留原值的问题,简单使用Excel的函数即可以实现.

  9. Last_Errno: 1396

    Last_Errno: 1396   Last_Error: Error 'Operation CREATE USER failed for 'usera63'@'%'' on query. Defa ...

  10. Git学习环境搭建和git对用户的增删改查命令

    git安装 windows下安装git git下载进入网址: https://git-scm.com/downloads 点击下载,进行安装,安装成功,你会看到图标,点击进入到git bash 查看g ...