因为k很小,所以转为二进制后暴力枚举。
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
#define LL long long
const int maxn = 1e5 + 10;
int a[maxn][10],vis[maxn];
int main()
{
int n, k, tmp;
scanf("%d%d", &n, &k);
for (int i = 1; i <= n; i++)
{
tmp = 0;
for (int j = 0; j < k; j++)
{
scanf("%d", &a[i][j]);
if (a[i][j])tmp += (1 << j);
}
vis[tmp] = 1;
}
int sum = 0;
for (int i = 0; i < k; i++)sum += (1 << i);
for (int i = 0; i <= sum; i++)
{
for (int j = 0; j <= sum; j++)
{
if (vis[i] && vis[j] && (i & j) == 0)
{
printf("YES\n");
return 0;
}
}
}
printf("NO\n");
return 0;
}