Codeforce 868 C Qualification Rounds (计数原理)

来源:互联网 发布:微博怎么设置个性域名 编辑:程序博客网 时间:2024/05/18 22:15

we need a lot of patience on this question
:http://codeforces.com/problemset/problem/868/C

Let’s talk about the method ,we can only find two question that has no intersection then that ‘ll be it!
because we want to choose minimum of question.If we can chose one question that no team knows it , we can definitely chose it . And if there are two more question that make a good set ,just two of them is fine.

if we directly fin all the question , we will get a tle then we
can iter all the situation of teams knows problem

#include <bits/stdc++.h>#define ll long longusing namespace std;int cnt[20];int main(){    ios::sync_with_stdio(0);    int x,n,k;    cin>>n>>k;    for(int i = 0;i<n;i++)    {        int s = 0;        for(int j = 0;j<k;j++)        {            int x = 0;            cin>>x;            s  = s * 2+x;        }        cnt[s]++;    }    for(int i = 0;i<(1<<k);i++)    {        for(int j = 0;j<(1<<k);j++)        {            if(cnt[i]>0&&cnt[j]>0 && (i&j)  == 0)            {                return cout<<"YES"<<endl,0;            }        }    }    cout<<"NO"<<endl;    return 0;}
原创粉丝点击