codeforce868c

探讨了如何为有经验的参赛团队设计合理的比赛问题集。在比赛中,每支队伍已知的题目不能超过所选题目的半数。通过算法判断是否能创建一个满足条件的问题集合。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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!

Input

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.

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
题意:有n道题,k个队伍。已知这些队伍认识的题目。现在要你定制一个比赛,要求比赛中的题目每个队认识的不能超过一半,问是否可能。

原文章传送门

#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <functional>
#define inf 1000000
using namespace std;
typedef long long ll;
const int MAXN=1e5+10;
const int MAX=1e5+10;
const double eps=1e-6;

int n,k;
int vis[20];

int main(){
    #ifdef ONLINE_JUDGE
    #else
    freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    #endif

    int juge=0;
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        int t,temp=0;
        for(int j=1;j<=k;j++){
            scanf("%d",&t);
            if(t)
                temp+=pow(2,j-1);
        }
        vis[temp]=1;
    }
    for(int i=0;i<=16;i++){
        for(int j=0;j<=16;j++){
            if(!(i&j)&&vis[i]&&vis[j])
                juge=1;
        }
    }
    if(juge)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;


    return 0;   
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值