原题链接: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. 【HANA系列】SAP HANA STUDIO客户端升级更新

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[HANA系列]SAP HANA STUDIO客 ...

  2. 关于BeautifulSoup4 解析器的说明

    一.解析器概述 如同前几章笔记,当我们输入: soup=BeautifulSoup(response.body) 对网页进行析取时,并未规定解析器,此时使用的是python内部默认的解析器“html. ...

  3. 精读《What's new in javascript》

    1. 引言 本周精读的内容是:Google I/O 19. 2019 年 Google I/O 介绍了一些激动人心的 JS 新特性,这些特性有些已经被主流浏览器实现,并支持 polyfill,有些还在 ...

  4. Java基础语法-运算符

    1算术运算符 1.1运算符和表达式 运算符:对常量和变量进行操作的符号. 表达式:用运算符把常量或者变量连接起来符合java语法的式子就可以称为表达式. 不同运算符链接的表达式体现的是不同类型的表达式 ...

  5. 【Linux 环境搭建】Ubuntu下安装tftp

    1.安装软件    sudo apt-get install tftp-hpa tftpd-hap xinetd 2.修改配置文件    sudo vim /etc/default/tftpd-hpa ...

  6. docker环境下分析zookeeper观察者角色

    问题引入 zookeeper新引入的角色observer是不参与投票的,通过增加observer节点,可以在提高zk系统读吞吐量时,不影响写吞吐量. 那么问题来了 Zookeeper系统节点如果超过半 ...

  7. 使用CSDN-markdown编辑器粘贴代码块时崩溃问题解决

    原因:代码段换行符失效,所有代码一行显示 解决方法:使用Chrome浏览器即可解决(使用Microsoft Edge会出现此问题) 效果展示: # _*_ coding:utf-8 _*_ impor ...

  8. 2. Docker部署tomcat, nginx, redis,及docker私有仓库

    1. 部署tomcat 1.1 下载tomcat       docker pull tomcat:7-jre8 1.2 部署容器  docker run -di --name=tomcat -p 8 ...

  9. git Permanently added the RSA host key for IP address '13.250.177.223' to the list of known hosts.

    只要把那个ip地址添加进hosts列表中就可解决. 参见:https://blog.csdn.net/hunhun1122/article/details/79752125

  10. 出去就餐并且理解Express.js的基本知识

    Going out to eat and understanding the basics of Express.js出去就餐并且理解Express.js的基本知识 原文:Going out to e ...