原题链接: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. python中的各个模块

    collection模块:python中的扩展数据模块#namedtuple: 生成可以使用名字来访问元素内容的tuple'''from collections import namedtuplePo ...

  2. expect实战

    1.测试主机是否在线 #!/bin/bash#创建一个IP地址文件.>ip.txt   (清空文本)#使用for循环ping测试主机是否在线.for i in {2..254}do        ...

  3. net 架构师-数据库-sql server-002-工具

    本章讲述的工具包括: SQL Server 联机丛书 SQL Server配置管理器 SQL Server Management Studio SQL Server Business Intellig ...

  4. 用nopcomerce3.8版本的同行注意了,前2天发布3.8正式版后,作者收到一些BuG,作者修复后重新提供了一个源代码包下载.

    用nopcomerce3.8版本的同行注意了,前2天发布3.8正式版后,作者收到一些BuG,作者修复后重新提供了一个源代码包下载地址,不是github上的那个链接.去作者官网论坛我那个链接地址,或关注 ...

  5. 【输入法】向Android端Gboard字典中导入PC端搜狗细胞词库

    [输入法]向Android端Gboard字典中导入PC端搜狗细胞词库 环境 Android 5.1.1 Gboard 8.7.10.272217667-release -armeabi-v7a PC端 ...

  6. HNUSTOJ-1253 Babelfish(字典树)

    1253: Problem C: Babelfish 时间限制: 1 Sec  内存限制: 128 MB提交: 14  解决: 3[提交][状态][讨论版] 题目描述 Problem C: Babel ...

  7. 剑指offer-用两个栈实现队列-栈和队列-python

    题目描述 用两个栈来实现一个队列,完成队列的Push和Pop操作. 队列中的元素为int类型.   # -*- coding:utf-8 -*- class Solution: def __init_ ...

  8. 使用vscode来代替git上传代码到仓库

    一.在上传前的注意事项 1. 要配置几个文件: (1)在根目录添加 .gitignore  文件:里面添加一些上传时需要忽略的文件 (2)在根目录添加 README.md  文件,这个用来说明项目的 ...

  9. 猿题库 iOS 客户端架构设计(原文地址:http://gracelancy.com/blog/2016/01/06/ape-ios-arch-design/)

    猿题库 iOS 客户端架构设计 序 猿题库是一个拥有数千万用户的创业公司,从2013年题库项目起步到2015年,团队保持了极高的生产效率,使我们的产品完成了五个大版本和数十个小版本的高速迭代.在如此快 ...

  10. github配置及使用

    安装git 对于linux系统,不同发行版本的安装方法不一样,请参考https://git-scm.com/download/linux.以ubuntu为例: sudo add-apt-reposit ...