Codeforces 868 C. Qualification Rounds (skill) _ Common skills

Source: Internet
Author: User
Tags rounds
Description

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 of it as a subset.

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.

Determine if Snark and Philip can make a interesting problemset!

Input

The contains two integers n, K (1≤n≤10^5, 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 are 1 if j-th team knows i-th problem and 0 otherwise.

Output

Print "YES" (quotes for clarity), if it's possible to make a 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

examples Output

NO

the

Select some of the N-N-way topics so that everyone has no more than half of the questions mastered.

train of Thought

It is easy to think, as long as we choose two questions, and then determine whether the two questions to meet the question.

For each question each team's mastery we use a number of binary to indicate that a binary 1 1 for the corresponding team to master the problem.

Suppose the two problems selected are I,j i,j, if i&j=0 i\&j=0 that is to meet the question.

Today the CF drop is very serious, C C question before considering enumerating k=1,2,3,4 k=1,2,3,4, and then write to 3 3 when found can be merged, so there is the following code, and another about 3 3 of a judgment forgotten deleted, resulting in the final measurement WA wa.

The result of the final Test D D MLE MLE, the good score is gone, there may be a better solution. Like thousands of this suffix automatic machine + two points + random is heterodoxy slightly ~

To the end of their own not careful enough to work hard pot ~

AC Code

 #include <bits/stdc++.h> using namespace std; const int MAXN = 1E5+10;
int n,k;
BOOL Mp[maxn][5];

int KKK[MAXN];
    int main () {Ios::sync_with_stdio (false);
    Cin.tie (0);
    cin>>n>>k;
    for (int i=0; i<n; i++) for (int j=0; j<k; j + +) cin>>mp[i][j];
    BOOL flag = FALSE;
        for (int i=0; i<n; i++) {int num = 0;
        for (int j=0; j<k; J + +) if (Mp[i][j]) num|=1<<j;
    kkk[num]++; for (int i=0; i<1<<k; i++) for (int j=0; j<1<<k; J + +) if ((I&j) ==0&& (
    KKK[I]&&KKK[J]) flag = true; cout<< (flag?)
    Yes ":" NO ") <<endl;
return 0; }
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.