Codeforces Round #438 C. Qualification Rounds
来源:互联网 发布:北京淘宝美工培训2ds 编辑:程序博客网 时间:2024/05/21 04:16
Snark and Philip are preparing the problemset for the upcoming pre-qualification round for semi-quarter-finals. They have a bank of nproblems, 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!
The first line contains two integers n, k (1 ≤ n ≤ 105, 1 ≤ k ≤ 4) — the number of problems and the number of experienced teams.
Each of the next n lines contains k integers, each equal to 0 or 1. The j-th number in the i-th line is 1 if j-th team knows i-th problem and 0 otherwise.
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").
5 31 0 11 1 01 0 01 0 01 0 0
NO
3 21 01 10 1
YES
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 0
1 1
1 1
0 1
0 1
0 0
0 0
3 三支队伍的时候,我们把它们拆成两个队伍(团队2)和一个队伍(团队1),团队2的情况已经证明过了,2*a行纯色点(纯黑a行纯白a行),2*(y-a)行间色点(左黑右白y-a行,左白右黑y-a行)0<=a<=y;如果我们有纯白的一行点,就是a>=1;我们就取这行点,因为在团队2的情况下,这行和任意一行都是可以搭配的,及满足条件,所以不管对应的团队1是黑点白点,取另一行相反颜色的点就好了。因为一列有y个黑点y个白点,所以必然存在。
那么现在如果a==0呢?就是团队2有y行是左黑右白,有y行是左白右黑我们先任意取一行,假设这行左黑右白(左白右黑也一样)那么能和它对应的左白右黑的行有y行,然后不管我们取的这行对应团队1是什么颜色,所有的行中剩下的同色的个数只剩y-1个,所以就算对应团队二的y行里有y-1行同色,那也还剩一行是绝对不同色的,所以三个队伍也满足这个条件。
1 0 0
1 1 1
0 0 1
0 1 0
1 0 1
1 1 0
0 1 0
0 0 1
4 四个队伍拆成两个队伍和两个队伍的,我们先称这两个队伍为团队1与团队2;
团队1和团队2也满足之前所说的条件( 2*a行纯色点(纯黑a行纯白a行),2*(y-a)行间色点(左黑右白y-a行,左白右黑y-a行)0<=a<=y;)假设团队1有2*a行纯色,团队2有2*b行纯色,如果都有纯色,即(a>=1&& b>=1)那么就取两个团队中纯白的那行就好了呗,团队1和团队2的纯白不在一行那么就取这两行就好了,如果在一行那么就取这一行,另一行任意取都无所谓。
如果只有一团队1有纯色另一个团队2没有纯色呢,一样的,其中有纯色的团队1取纯白色那行,然后不管团队2是左黑右白还是左白右黑,取另一行团队2的对应色就好了,因为团队1纯白色那行和任意行都可以对应。
最后只有一个情况,就是a==0 && b==0两个团队都没有纯色行咋整
0 0 0 0
0 0 0 0
1 1 1 1
1 1 1 1
1 1 0 0
1 0 1 1
0 1 0 1
0 0 1 0
1 1 0 1
1 0 1 0
0 1 0 1
1 0 1 0
1 0 1 0
1 0 1 0
0 1 1 0
0 1 0 1
0 1 0 1
0 1 0 1
#include <iostream>#include <cstdio>#include <algorithm>#include <cmath>using namespace std;int a[16]={0};int main() { int n,k,x; scanf("%d%d",&n,&k); for (int i=1; i<=n; i++) { int s=0; for(int j=1;j<=k;j++) { scanf("%d",&x); s=s*2+x; } a[s]++; } bool f=false; for(int i=0;i<=int(pow(2,k))-1;i++) { if(a[i]>0) for (int j=0; j<=int(pow(2, k))-1; j++) { if(a[j]>0) { if((i&j)==0) f=true; } } } if (f) { printf("YES\n"); } else printf("NO\n"); // insert code here... //std::cout << "Hello, World!\n"; return 0;}
- 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
- Codeforces Round #438 C Qualification Rounds(暴力+位运算)
- Codeforces Round #438 C 868C Qualification Rounds(思维,非状压dp)
- Codeforces 868 C Qualification Rounds
- codeforces 868C Qualification Rounds
- Codeforces round438 C. Qualification Rounds
- codeforces 868C Qualification Rounds
- Codeforces 868C Qualification Rounds
- Codeforces 868C Qualification Rounds
- CodeForces 868C Qualification Rounds
- codeforces 868C Qualification Rounds
- Codeforces Round #438 (Div. 1 + Div. 2 combined) C. Qualification Rounds
- 【状态压缩 && 思维转换】Codeforces Round #438 868C Qualification Rounds
- Codeforces Round #438 C.Qualification Rounds(状态压缩再枚举状态)
- Python发展迅速的原因分析
- php JSON数据格式化方法
- ►奇说总002期:《战争中隐秘的智慧较量》10.12
- 每日区块链:日本三家银行巨头联合开展区块链P2P转账“现场测试”;IBM、超级账本加入区块链身份联盟
- 非旋转/可持久化treap(转自Sengxian's Blog)
- Codeforces Round #438 C. Qualification Rounds
- Spring 支持 Restful风格 源码分析
- 一张图,告诉你什么是js执行上下文
- Codeforces 808F Card Game(和是素数二分图建图+二分图带权最大独立集)
- 全球最大成人网站 PornHub 也用上了AI,目的是让用户更 Happy
- 马云豪掷三千亿,你又如何能分到100个月季度奖?
- Python中的排序
- iOS【根据经纬度获取地名,根据地名获取经纬度】
- 指针常量、常量指针;指针数组、数组指针;指针函数、函数指针