原题链接:http://codeforces.com/problemset/problem/868/C

题意:有k个队伍参加比赛,比赛有n个预选的题目,有些队伍对已经事先知道了一些题目。问能不能选出若干个题,使没有队伍提前知道了半数以上的比赛题目。

思路:可以肯定的是,只要存在满足条件的选题方案,必定存在两道题,选上这两道之后也是满足条件的。因为k<=4,我们可以用二进制数记录题目的被提前知道的情况。所以,只要存在两个题目,对应的二进制数的异或结果为0,输出YES,否则输出NO。具体实现参看代码

AC代码:

#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int num[];
int main()
{
int n,k;
int m,p;
scanf("%d %d", &n, &k);
for(int i=;i<n;i++){
p=;
for(int j=;j<k;j++){
scanf("%d", &m);
p^=m;
p<<=;
}
//cout<<p<<endl;
num[p]++;
}
p=;
for(int i=;i<k;i++){
p=p^;
p<<=;
}
bool flag=;
//cout<<int(2^15)<<endl;
if(num[])
flag=;
for(int i=;i<=p;i++){
for(int j=;j<=p;j++){
if(!(i&j)&&(num[i]&&num[j])){
flag=;
break;
}
}
}
if(flag)
printf("YES\n");
else
printf("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

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

  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. (四) appium-desktop 脚本录制常用AW使用介绍

    通过使用appium-desktop录制脚本,编写app自动化脚本的过程中,会使用到一些AW,下面就这些AW的使用方法做详细的介绍.通过实践可以看到这几个AW可以完成测试工作. AWOpenGiveP ...

  2. 【ABAP系列】SAP 如何用ABAP实现自动发送外部邮件

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP 如何用ABAP实现自动发 ...

  3. Android - Retrofit 2.0 使用教程(含实例讲解)

    链接:https://blog.csdn.net/carson_ho/article/details/73732076

  4. Go语言入门篇-jwt(json web token)权限验证

    一.token.cookie.session的区别 1.cookie Cookie总是保存在客户端中,按在客户端中的存储位置,可分为内存Cookie和硬盘Cookie. 内存Cookie由浏览器维护, ...

  5. JSON.toJSONString时保留null值

    QuoteFieldNames———-输出key时是否使用双引号,默认为true WriteMapNullValue——–是否输出值为null的字段,默认为false WriteNullNumberA ...

  6. strtoul()要优于atoi()函数---C语言

    strtoul():将字符串转为长整型整数 atoi():将字符串转为整型整数 在32位STM32中,int是32位的,如果字符串是“3123456789”,大于0x7fff fff,用atoi()函 ...

  7. Selenium1.0与2.0介绍

    Selenium的实现原理 首先,你要明确刚才建立的测试用例是基于Selenium 2.0,也就是Selenium + WebDriver的方案.其次,你需要知道,对Selenium而言,V1.0和V ...

  8. j网络爬虫之WebMagic

    WebMagic官网:http://webmagic.io/ 注意: 1.在自定义PageProcessor中使用System.out.println(“str”),Spider.create(new ...

  9. spark数据结构之RDD

    学习spark,RDD是一个逃不过去的话题,那么接下来我们看看RDD 1.什么是RDD? RDD叫做弹性分布式数据集,是Spark中最基本的数据抽象,代表一个不可变.可分区.里面元素可以并行计算的集合 ...

  10. Redis持久化rdb&aof

    Redis持久化rdb&aof 前言 持久化:即把数据存储于断电后不会丢失的设备中,通常是硬盘 常见的持久化方式: 主从:通过从服务器保持持久化,如mongoDB的replication se ...