原题链接: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. Alert弹出框处理

    selenium的API提供了Alert类对alert弹出框的处理的方法,涉及到的方法有text,dismiss(),accept()和send_keys(),在javascript中主要有alert ...

  2. jmeter常用性能监听器分析

    jmeter中提供了很多性能数据的监听器,我们通过监听器可以来分析性能瓶颈 本文以500线程的阶梯加压测试结果来描述图表. 常用监听器 1:Transactions per Second 监听动态TP ...

  3. webpack4下url-loader打包图片问题

      webpack.condig.js: const path = require('path'); //导入插件 const VueLoaderPlugin = require('vue-loade ...

  4. python 如何解决高并发下的库存问题??

    python 提供了2种方法解决该问题的问题:1,悲观锁:2,乐观锁 悲观锁:在查询商品储存的时候加锁 select_for_update()  在发生事务的commit或者是事务的rollback时 ...

  5. 使用 ref 和 out 传递数组注意事项

    1.与所有的 out参数一样,在使用数组类型的 out 参数前必须先为其赋值,即必须由被调用方为其赋值 示例 :在此例中,在调用方(Main 方法)中声明数组 theArray,并在 FillArra ...

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

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

  7. Kibana 基本操作

    es中的索引对应mysql的数据库.类型对应mysql的表.文档对应mysql的记录.映射对应mysql的索引索引:index类型:type映射:mappings 1.创建索引在kibana的Dev ...

  8. 禁止input输入框历史记录

    <input type="text" autocomplete="off" />

  9. Java多线程(1)

    线程与进程 进程:程序的执行过程 线程:线程共享进程的资源 Java多线程 实现的方式 继承Tread类:使用getName()获取当前线程名 实现Runnable接口:Thread.currentT ...

  10. python初步学习

    一.字符编码 ASCII表是是基于拉丁字母的一套电脑编码系统,主要用于显示现代英语和其他西欧语言,其最多只能用 8 位来表示(一个字节),即:2**8 = 256-1,所以,ASCII码最多只能表示 ...