Codeforces Round #438 C. Qualification Rounds 题解
来源:互联网 发布:xl player for mac 编辑:程序博客网 时间:2024/05/21 02:22
C. Qualification Rounds
time limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard output
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
Note
In the first example you can’t make any interesting problemset, because the first team knows all problems.
In the second example you can choose the first and the third problems.
前三种暴力判,第四种手写
#include <bits/stdc++.h>#define digit (ch < '0' || ch > '9')using namespace std;template <class T> inline void read(T &x) { int flag = 1; x = 0; register char ch = getchar(); while( digit) { if(ch == '-') flag = -1; ch = getchar(); } while(!digit) { x = (x<<1)+(x<<3)+ch-'0'; ch = getchar(); } x *= flag;}const long long maxn = 1e5+10;map <string, long long> r;long long a[maxn][10],c[maxn],d[10];long long ans1,ans2,n,k,maxx;int main() { read(n); read(k); for(register long long i = 1; i <= n; i++) { for(register long long j = 1; j <= k; j++) read(a[i][j]), c[i] += a[i][j], d[j] += a[i][j], maxx = max(maxx, d[j]); ans1 += (!c[i]) ? 1 : 0, ans2 += (c[i] == 1) ? 1 : 0; } if(maxx == n) { printf("NO"); return 0; } if(ans2 > 0 || ans1 > 0) { printf("YES"); return 0; } if(k < 4) { printf("NO"); return 0; } for(register long long i = 1; i <= n; i++) { string s = ""; for(register long long j = 1; j <= k; j++) s += char('0'+a[i][j]); r[s]++; } if(r["1100"] > 0 && r["0011"] > 0) printf("YES"); else if(r["1010"] > 0 && r["0101"] > 0) printf("YES"); else if(r["1001"] > 0 && r["0110"] > 0) printf("YES"); else printf("NO"); return 0;}
- Codeforces Round #438 C. Qualification Rounds 题解
- Codeforces Round #438 C. Qualification Rounds
- Codeforces Round #438 C. Qualification Rounds 二进制
- codeforces round #438 C. Qualification Rounds
- Codeforces Round #438 C. Qualification Rounds
- Codeforces Round #438 C Qualification Rounds(暴力+位运算)
- Codeforces Round #438 C 868C Qualification Rounds(思维,非状压dp)
- Codeforces 868 C Qualification Rounds
- codeforces 868C Qualification Rounds
- Codeforces round438 C. Qualification Rounds
- codeforces 868C Qualification Rounds
- Codeforces 868C Qualification Rounds
- Codeforces 868C Qualification Rounds
- CodeForces 868C Qualification Rounds
- codeforces 868C Qualification Rounds
- Codeforces Round #438 (Div. 1 + Div. 2 combined) C. Qualification Rounds
- 【状态压缩 && 思维转换】Codeforces Round #438 868C Qualification Rounds
- Codeforces Round #438 C.Qualification Rounds(状态压缩再枚举状态)
- 静态链接的过程
- asp.net 不同应用程序在IIS发布后实现Session共享
- juqery--获取json数据后一次性填充表单数据的方法
- 影响机器视觉光源效果的因素有哪些?
- redis企业级数据备份和恢复方案
- Codeforces Round #438 C. Qualification Rounds 题解
- Python自学记录_入门(变量)
- Android断点续传学习
- LeetCode-Excel Sheet Column Number/Title
- 数据结构——第六讲、图(上)(1)
- 字符串的全排列
- form表单 onsubmit 坑爹之旅
- 从源码级别了解PHP %00截断原理
- crontab定时任务脚本不执行,日志无执行记录