Codeforces 868C Qualification Rounds
来源:互联网 发布:淘宝qps 编辑:程序博客网 时间:2024/05/21 03:19
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output
Snark and Philip are preparing the problemset for the upcoming pre-qualification round for semi-quarter-finals. They have a bank of
Determine if Snark and Philip can make an interesting problemset!
Input
The first line contains two integers
Each of the next
Output
Print “YES” (quotes for clarity), if it is possible to make an interesting problemset, and “NO” otherwise.
You can print each character either upper- or lowercase (“YeS” and “yes” are valid when the answer is “YES”).
Examples
input
5 3
1 0 1
1 1 0
1 0 0
1 0 0
1 0 0
output
NO
input
3 2
1 0
1 1
0 1
output
YES
Note
In the first example you can’t make any interesting problemset, because the first team knows all problems.
In the second example you can choose the first and the third problems.
初看很复杂,其实答案简单到让人怀疑人生。
这么说吧,因为1.是subset,2.对subset的大小没有要求,3.要求所有队都最多只会一半的题,那么就挑所有队要么都不会,要么只会其中一题的两题就好了。由于最多只会有4个队,于是每一题的情况最多只有16种:没有人会,只有第一个队会,只有第二个队会,只有第一和第二个队会,只有第三个队会,只有第一和第三个队会,etc……换言之就是0000 0001 0010 0011 0100 0101 etc……那么这样的两题(假设分别为a和b)必须有a^b==0,但是不可能直接两层for的,因为那是
于是便有了这样的策略:只要有0000,那么再来一题(无论是怎样的一题)就好;只要有0001,那么再来一题0010/0100/0110/1000/1010/1100/1110就好;etc。将题目情况转换为数字的操作,记录题目的有无都可以在输入的时候顺带进行;剩下的就
#include<stdio.h>#include<string.h>#include<algorithm>#include<vector>#include<set>#include <iterator>#include<set>using namespace std;typedef long long ll;int n,k;int solved[100005];bool has[16];int nthbit[4] = {1,2,4,8};bool nohas(){ for(int i=1;i<16;i++){ if(has[i])return false; } return true;}int main(){ scanf("%d%d",&n,&k); int A = nthbit[k]-1; bool flag=false; for(int i=0;i<n;i++){ for(int j=0;j<k;j++){ int a; scanf("%d",&a); if(a==1)solved[i]|=nthbit[j]; } has[solved[i]]=true; }// for(int i=0;i<n;i++)printf("%d ",solved[i]);printf("\n"); if( has[0]&&(has[1]||has[2]||has[3]||has[4]||has[5]||has[6]||has[7]||has[8]||has[9]||has[10]||has[11]||has[12]||has[13]||has[14]||has[15]) || has[1]&&(has[2]||has[4]||has[6]||has[8]||has[10]||has[12]||has[14]) || has[2]&&(has[1]||has[4]||has[8]||has[5]||has[9]||has[12]||has[13]) || has[3]&&(has[4]||has[8]||has[12]) || has[4]&&(has[1]||has[2]||has[3]||has[8]||has[9]||has[10]||has[11]) || has[5]&&(has[2]||has[8]||has[10]) || has[6]&&(has[1]||has[8]||has[9]) || has[7]&&(has[8]) || has[8]&&(has[1]||has[2]||has[3]||has[4]||has[5]||has[6]||has[7]) || has[9]&&(has[2]||has[4]||has[6]) || has[10]&&(has[1]||has[4]||has[5]) || has[11]&&(has[4]) || has[12]&&(has[1]||has[2]||has[3]) || has[13]&&(has[2]) || has[14]&&(has[1]) || nohas() ) {flag=true;} printf((flag?"YES\n":"NO\n")); return 0;}
- Codeforces 868 C Qualification Rounds
- codeforces 868C Qualification Rounds
- codeforces 868C Qualification Rounds
- Codeforces 868C Qualification Rounds
- Codeforces 868C Qualification Rounds
- CodeForces 868C Qualification Rounds
- codeforces 868C Qualification Rounds
- Codeforces 868 C. Qualification Rounds (技巧)
- Codeforces 868C Qualification Rounds【思维】
- Codeforces 868C Qualification Rounds 结论
- Codeforces round438 C. Qualification Rounds
- codeforces 868C.Qualification Rounds(bitmasks与状压dp)
- Codeforces Round #438 C. Qualification Rounds
- Codeforces Round #438 C. Qualification Rounds 二进制
- codeforces round #438 C. Qualification Rounds
- Codeforces Round #438 C. Qualification Rounds 题解
- Codeforces Round #438 C. Qualification Rounds
- CF 868 C. Qualification Rounds 【状态压缩】
- java基础知识面试题
- 11. 迭代器模式
- Firefox F12 + Python 3.6 下载B站视频
- rabbitmq安装
- 九度 1363 欢乐打扑克 【简单水题暴力模拟】
- Codeforces 868C Qualification Rounds
- centos虚拟机网络配置NAT模式和桥接模式总结
- 6.4OpenCV中值滤波
- linux系统基本命令(八)
- 制作一份手机录屏的 GIF 动态图片
- python模块之urllib2基本爬虫入门
- Python学习笔记:生成器与迭代器
- python中包的使用总结
- 制作打怪小游戏Kill Bill