Description

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!

解题报告:

猜一个结论:如果存在答案,那么一定存在只由两个问题组成的problemset的解,所以枚举一个串,另一个串用桶判断即可

#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#define RG register
#define il inline
#define iter iterator
#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a)<(b)?(a):(b))
using namespace std;
const int N=1e5+5,K=6;
int t[3][3][3][3],f[6],n,k;int map[N][K];bool flag=false;
void dfs(int x,int dep){
if(dep==k+1){
if(t[f[1]][f[2]][f[3]][f[4]])flag=true;
return ;
}
if(flag)return ;
if(map[x][dep])f[dep]=false,dfs(x,dep+1);
else{
f[dep]=true;dfs(x,dep+1);
f[dep]=false;dfs(x,dep+1);
}
}
void work()
{
cin>>n>>k;
for(int i=1;i<=n;i++){
for(int j=1;j<=k;j++){
scanf("%d",&map[i][j]);
}
t[map[i][1]][map[i][2]][map[i][3]][map[i][4]]++;
}
memset(f,0,sizeof(f));
for(int i=1;i<=n;i++){
flag=false;
dfs(i,1);
if(flag){
puts("YES");
return ;
}
}
puts("NO");
} int main()
{
work();
return 0;
}

Codeforces Round #438 C. Qualification Rounds的更多相关文章

  1. Codeforces Round #438 C - Qualification Rounds 思维

    C. Qualification Rounds time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  2. Codeforces Round #438 (Div.1+Div.2) 总结

    本来兴致勃勃的想乘着这一次上紫,于是很早很早的到了机房 但是好像并没有什么用,反而rating-=47 Codeforces Round #438(Div.1+Div.2) 今天就这样匆匆的总结一下, ...

  3. [Codeforces Round #438][Codeforces 868C. Qualification Rounds]

    题目链接:868C - Qualification Rounds 题目大意:有\(n\)个题目,\(k\)个人,每个人可能做过这\(n\)个题里的若干道,出题方要在这\(n\)个题目里选若干个出来作为 ...

  4. Codeforces Round #438 by Sberbank and Barcelona Bootcamp (Div. 1 + Div. 2 combined)

    A. Bark to Unlock 题目链接:http://codeforces.com/contest/868/problem/A 题目意思:密码是两个字符组成的,现在你有n个由两个字符组成的字符串 ...

  5. Codeforces Round #438 by Sberbank and Barcelona Bootcamp (Div. 1 + Div. 2 combine

    最近只想喊666,因为我是真得菜,大晚上到网吧打代码还是很不错的嘛 A. Bark to Unlock time limit per test 2 seconds memory limit per t ...

  6. 【Codeforces Round 438 A B C D 四个题】

    题目所在比赛的地址在这里呀 A. Bark to Unlock ·述大意:       输入一个目标串.然后输入n(1<=n<=100)个串,询问是否可以通过这些串收尾相接或者它本身拼出目 ...

  7. 【Codeforces Round #438 C】 Qualification Rounds

    [链接]h在这里写链接 [题意] 给你n个问题,每个人都知道一些问题. 然后让你选择一些问题,使得每个人知道的问题的数量,不超过这些问题的数量的一半. [题解] 想法题. 只要有两个问题. 这两个问题 ...

  8. Qualification Rounds(Codeforces Round #438 by Sberbank and Barcelona Bootcamp (Div. 1 + Div. 2 combined)+状态压缩)

    题目链接 传送门 题意 现总共有\(n\)个题目\(k\)支参赛队伍,已知每个题目各队伍是否会写,现问你能否从题目中选出一个子序列使得每支队伍最多只会写一半的题目. 思路 对于每个题目我们用二进制压缩 ...

  9. Codeforces Round #438 B. Race Against Time

    Description Have you ever tried to explain to the coordinator, why it is eight hours to the contest ...

随机推荐

  1. 201621123068 《Java程序设计》第1周学习总结

    1. 本周学习总结 本周学习了如何使用Java来编写程序,还没展开学习具体的语言,但是也花了大量的时间搞清楚Java运行的原理.明白了Java是一种可以跨平台运行语言,搞清了jdk,jre,jvm之间 ...

  2. 2017 清北济南考前刷题Day 3 morning

    实际得分:100+0+0=100 T1 右上角是必败态,然后推下去 发现同行全是必胜态或全是必败态,不同行必胜必败交叉 列同行 所以n,m 只要有一个是偶数,先手必胜 #include<cstd ...

  3. 从PRISM开始学WPF(六)MVVM(二)Command?

    从PRISM开始学WPF(一)WPF? 从PRISM开始学WPF(二)Prism? 从PRISM开始学WPF(三)Prism-Region? 从PRISM开始学WPF(四)Prism-Module? ...

  4. Mysql-5.7.21安装配置

    搞开发多年,其实MySql前前后后安装配置了无数次,但是每次都需要到网上搜教程,折腾半天才搞定,这次索性把整个过程全部记录下来,以便以后查阅. 下载 到MySql官网,导航找到DOWNLOADS> ...

  5. Andrew Ng机器学习第一章——单变量线性回归

    监督学习算法工作流程 h代表假设函数,h是一个引导x得到y的函数 如何表示h函数是监督学习的关键问题 线性回归:h函数是一个线性函数 代价函数 在线性回归问题中,常常需要解决最小化问题.代价函数常用平 ...

  6. Python内置函数(65)——staticmethod

    英文文档: staticmethod(function) Return a static method for function. A static method does not receive a ...

  7. python __str__ 和__repr__方法

    看下面的例子就明白了 class Test(object): def __init__(self, value='hello, world!'): self.data = value >> ...

  8. Spring知识点回顾(04)el 和资源使用

    注入普通字符 注入操作系统属性 注入表达式运算结果 注入其他bean属性 注入文件内容 注入网址内容 注入属性文件

  9. python入门(10)使用List和tuple

    python入门(10)使用List和tuple list Python内置的一种数据类型是列表:list.list是一种有序的集合,可以随时添加和删除其中的元素. 比如,列出班里所有同学的名字,就可 ...

  10. Delaunay三角化算法

    参考:<平面域中的Delaunay三角算法>