codeforces 868C Qualification Rounds
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个为题,每个问题被一些球队知道,现能否选出一些问题,使得每个队知道的问题至多一半
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
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的更多相关文章
- [Codeforces Round #438][Codeforces 868C. Qualification Rounds]
题目链接:868C - Qualification Rounds 题目大意:有\(n\)个题目,\(k\)个人,每个人可能做过这\(n\)个题里的若干道,出题方要在这\(n\)个题目里选若干个出来作为 ...
- Codeforces 868C Qualification Rounds - 位运算
Snark and Philip are preparing the problemset for the upcoming pre-qualification round for semi-quar ...
- codeforces 868C - Qualification Rounds(构造)
原题链接:http://codeforces.com/problemset/problem/868/C 题意:有k个队伍参加比赛,比赛有n个预选的题目,有些队伍对已经事先知道了一些题目.问能不能选出若 ...
- 【Codeforces】868C. Qualification Rounds
[题目]C. Qualification Rounds [题意]给定n个问题和K个人,给定每个人知道的问题列表,求能否找到一个非空问题集合,满足每个人知道的集合中问题数量都不超过集合总题数的一半.n& ...
- F - Qualification Rounds CodeForces - 868C 二进制
F - Qualification Rounds CodeForces - 868C 这个题目不会,上网查了一下,发现一个结论就是如果是可以的,那么两个肯定可以满足. 然后就用二进制来压一下这个状态就 ...
- Codeforces Round #438 C - Qualification Rounds 思维
C. Qualification Rounds time limit per test 2 seconds memory limit per test 256 megabytes input stan ...
- codeforces 868C
C. Qualification Rounds time limit per test 2 seconds memory limit per test 256 megabytes input stan ...
- Codeforces Round #438 C. Qualification Rounds
Description Snark and Philip are preparing the problemset for the upcoming pre-qualification round f ...
- 【Codeforces Round #438 C】 Qualification Rounds
[链接]h在这里写链接 [题意] 给你n个问题,每个人都知道一些问题. 然后让你选择一些问题,使得每个人知道的问题的数量,不超过这些问题的数量的一半. [题解] 想法题. 只要有两个问题. 这两个问题 ...
随机推荐
- 20145237 实验一 逆向与Bof基础
20145237 实验一 逆向与Bof基础 1.直接修改程序机器指令,改变程序执行流程 此次实验是下载老师传给我们的一个名为pwn1的文件. 首先,用 objdump -d pwn1 对pwn1进行反 ...
- SciPy - 科学计算库(上)
SciPy - 科学计算库(上) 一.实验说明 SciPy 库建立在 Numpy 库之上,提供了大量科学算法,主要包括这些主题: 特殊函数 (scipy.special) 积分 (scipy.inte ...
- asp.net web api 控制器
1控制器操作的参数 控制器操作的参数可以是内置类型也可以是自定义类型,无参也是允许的. 2控制器操作返回值 类型 说明 void 操作返回值为void时,Web API返回空HTTP响应,其状态码为2 ...
- 老帖收藏,留供参考:SpringMvc2.5+Mybatis3.2.7
一.项目背景 SpringMvc+Mybatis 数据库连接池是阿里巴巴的druid.日志框架式logback 二.配置文件 1.SpringMvc-servlet.xml <?xml vers ...
- ELK学习总结(4-1)elasticsearch更改mapping(不停服务重建索引)
elasticsearch更改mapping(不停服务重建索引)原文 http://donlianli.iteye.com/blog/1924721Elasticsearch的mapping一旦创建, ...
- zuul入门(4)zuul的注解@EnableZuulServer和@EnableZuulProxy
@EnableZuulServer.@EnableZuulProxy两个注解 @EnableZuulProxy简单理解为@EnableZuulServer的增强版,当Zuul与Eureka.Ribbo ...
- SOAPtest报错:error occurred during initialization of vm解决方法
参考:http://forums.parasoft.com/index.php?act=ST&f=36&t=614 安装SOAPtest报错:error occurred during ...
- 浅显易懂的谈一谈python中的装饰器!!
hello大家好~~我是稀里糊涂林老冷,一天天稀里糊涂的. 前一段时间学习了装饰器,觉着这东西好高大上哇靠!!哈哈,一定要总结一下,方便以后自己查阅,也希望帮助其他伙伴们共同进步! 装饰器: 大家可以 ...
- RxJava系列4(过滤操作符)
RxJava系列1(简介) RxJava系列2(基本概念及使用介绍) RxJava系列3(转换操作符) RxJava系列4(过滤操作符) RxJava系列5(组合操作符) RxJava系列6(从微观角 ...
- JavaScript是如何面向对象的
一.引言 在16年的10月份,在校内双选会找前端实习的时候,hr问了一个问题:JavaScript的面向对象理解吗?我张口就说"JavaScript是基于原型的!".然后就没什么好 ...