Codeforces Round #438 C. Qualification Rounds
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的更多相关文章
- Codeforces Round #438 C - Qualification Rounds 思维
C. Qualification Rounds time limit per test 2 seconds memory limit per test 256 megabytes input stan ...
- Codeforces Round #438 (Div.1+Div.2) 总结
本来兴致勃勃的想乘着这一次上紫,于是很早很早的到了机房 但是好像并没有什么用,反而rating-=47 Codeforces Round #438(Div.1+Div.2) 今天就这样匆匆的总结一下, ...
- [Codeforces Round #438][Codeforces 868C. Qualification Rounds]
题目链接:868C - Qualification Rounds 题目大意:有\(n\)个题目,\(k\)个人,每个人可能做过这\(n\)个题里的若干道,出题方要在这\(n\)个题目里选若干个出来作为 ...
- 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个由两个字符组成的字符串 ...
- 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 ...
- 【Codeforces Round 438 A B C D 四个题】
题目所在比赛的地址在这里呀 A. Bark to Unlock ·述大意: 输入一个目标串.然后输入n(1<=n<=100)个串,询问是否可以通过这些串收尾相接或者它本身拼出目 ...
- 【Codeforces Round #438 C】 Qualification Rounds
[链接]h在这里写链接 [题意] 给你n个问题,每个人都知道一些问题. 然后让你选择一些问题,使得每个人知道的问题的数量,不超过这些问题的数量的一半. [题解] 想法题. 只要有两个问题. 这两个问题 ...
- Qualification Rounds(Codeforces Round #438 by Sberbank and Barcelona Bootcamp (Div. 1 + Div. 2 combined)+状态压缩)
题目链接 传送门 题意 现总共有\(n\)个题目\(k\)支参赛队伍,已知每个题目各队伍是否会写,现问你能否从题目中选出一个子序列使得每支队伍最多只会写一半的题目. 思路 对于每个题目我们用二进制压缩 ...
- 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 ...
随机推荐
- 201621123060 《Java程序设计》第六周学习总结
1. 本周学习总结 1.1 面向对象学习暂告一段落,请使用思维导图,以封装.继承.多态为核心概念画一张思维导图或相关笔记,对面向对象思想进行一个总结. 注1:关键词与内容不求多,但概念之间的联系要清晰 ...
- python网络爬虫,知识储备,简单爬虫的必知必会,【核心】
知识储备,简单爬虫的必知必会,[核心] 一.实验说明 1. 环境登录 无需密码自动登录,系统用户名shiyanlou 2. 环境介绍 本实验环境采用带桌面的Ubuntu Linux环境,实验中会用到桌 ...
- JAVA_SE基础——39.继承
在面向对象程序设计中,可以从已有的类派生出新类. 这称做继承(inheritance). 白话解释: 例子1:继承一般是指晚辈从父辈那里继承财产,也可以说是子女拥有父母给予他们的东西. 例子2:猫和狗 ...
- Mybatis学习日志
在Mybatis深入学习的一周中,总感觉跟着师傅的视屏讲解什么都能懂,但实际自己操作的时候才发现自己一脸懵逼,不知道从何入手.但还好自己做了点笔记.在此记录一下自己浅度学习Mybatis遇到几个小问题 ...
- JavaScript 动态显示当前时间
代码如下: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <tit ...
- 剑指offer-反转单词顺序列
题目描述 牛客最近来了一个新员工Fish,每天早晨总是会拿着一本英文杂志,写些句子在本子上.同事Cat对Fish写的内容颇感兴趣,有一天他向Fish借来翻看,但却读不懂它的意思.例如,"st ...
- 解决IE8下CSS3选择器 :nth-child() 不兼容的问题
1.定义和用法 :nth-child(n) 选择器匹配属于其父元素的第 N 个子元素,不论元素的类型. n 可以是数字.关键词或公式. <ul> <li>1</li> ...
- redis入门(14)redis集群下的数据分区存储
redis入门(10)redis集群下的数据分区存储
- OrientDB入门(1)Getting Started
Running OrientDB the First Time First, download and extract OrientDB by selecting the appropriate pa ...
- 由路由器AP隔离引起的WEB服务不能访问的问题
最近在自己的电脑上运行了一个Web服务,发现它只能被本机访问,无法在同一个局域网的其它设备访问. 于是在网上搜索了各种资料,通通都是在操作系统层面来分析解决问题的. 而我怎么尝试都不成功的情况下,差点 ...