codeforces 868C Qualification Rounds
Posted Z-Y-Y-S
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了codeforces 868C Qualification Rounds相关的知识,希望对你有一定的参考价值。
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!
题目大意:
有n个为题,每个问题被一些球队知道,现能否选出一些问题,使得每个队知道的问题至多一半
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 3
1 0 1
1 1 0
1 0 0
1 0 0
1 0 0
NO
3 2
1 0
1 1
0 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.
ZYYS(贼有意思)
首先经分析发现,最好情况下只要2个就行了
因为假如选了2个不符条件,选了3个符合条件,那么显然可以只选其中2个
如果只选2个解决不了,那么显然多选也解决不了
把每一个问题的状态压缩,枚举所有状态,如果(i&j)==0那么就可以
1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 using namespace std; 6 int f[101],n,k,flag; 7 int main() 8 {int i,j,x; 9 cin>>n>>k; 10 for (i=1;i<=n;i++) 11 { 12 int cnt=0; 13 for (j=1;j<=k;j++) 14 { 15 scanf("%d",&x); 16 cnt+=(1<<j-1)*x; 17 } 18 f[cnt]=1; 19 } 20 flag=0; 21 for (i=0;i<16;i++) 22 for (j=0;j<16;j++) 23 if ((i&j)==0&&f[i]&&f[j]) 24 { 25 flag=1; 26 } 27 if (flag) cout<<"YES\n"; 28 else cout<<"NO\n"; 29 }
以上是关于codeforces 868C Qualification Rounds的主要内容,如果未能解决你的问题,请参考以下文章
codeforces 868C - Qualification Rounds(构造)
F - Qualification Rounds CodeForces - 868C 二进制
json QualificaçõesScrapperPersonal Virtual