codeforces 868C - Qualification Rounds (思维)

题目链接:https://codeforces.com/problemset/problem/868/C

如果有方案,那么肯定可以用两道题目完成
这是证明

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<stack>
#include<queue>
using namespace std;
typedef long long ll;

const int maxn = 100010;

int n,k;
int a[20];

ll read(){ ll s=0,f=1; char ch=getchar(); while(ch<'0' || ch>'9'){ if(ch=='-') f=-1; ch=getchar(); } while(ch>='0' && ch<='9'){ s=s*10+ch-'0'; ch=getchar(); } return s*f; }

int main(){
	memset(a,0,sizeof(a));
	n = read(), k = read();
	
	for(int i=1;i<=n;++i){
		int res = 0;
		for(int j=1;j<=k;++j){
			int p = read();
			res += (p<<(k-j));
		}
		++a[res];
	}
	
	int flag = 0;
	for(int i=0;i<(1<<k);++i){
		for(int j=0;j<(1<<k);++j){
			if(a[i] > 0 && a[j] > 0 && ((i&j)==0) ){
				flag = 1;
				printf("YES\n");
				break;
			}
		}
		if(flag) break; 
	}

	if(!flag){
		printf("NO\n");
	}
	
	return 0;
}
posted @ 2020-10-18 00:05  Tartarus_li  阅读(69)  评论(0编辑  收藏  举报