CodeFroces Round 438C. Qualification Rounds(思维题)
来源:互联网 发布:韧带 知乎 编辑:程序博客网 时间:2024/05/21 22:44
题意:给出n个题目,k个队伍是否刷过这题的情况表。现在要举办一场比赛,要求用的题目,不能有队伍已经刷过一半以上。问是否存在解。
解法:当时瞎写发现,好像只要选两个就可以了,然后就开始猜结论来写。由于k只有4,所以说最多只有1<<4种情况。直接转为二进制,暴力一下即可。
代码如下:
#include<iostream>#include<cstdio>#include<vector>#include<queue>#include<utility>#include<stack>#include<algorithm>#include<cstring>#include<string>#include<cmath>#include<set>#include<map>using namespace std;const int maxn = 1e5 + 5;int a[maxn], n, k;bool vst[maxn];int main() {#ifndef ONLINE_JUDGE//freopen("in.txt", "r", stdin);// freopen("out.txt", "w", stdout);#endifscanf("%d%d", &n, &k);for(int i = 0; i < n; i++) {int t = 0;for(int j = 0; j < k; j++) {int tmp;scanf("%d", &tmp); if (!tmp) {continue;} t |= (1 << j);}vst[t] = 1;}bool flag = 0;for(int i = 0; i < (1 << k); i++) {for(int j = i; j < (1 << k); j++) {if(!vst[i] || !vst[j])continue;if((i & j) == 0) {flag = 1;}}}if(flag)printf("YES\n");elseprintf("NO\n");return 0;}
阅读全文
0 0
- CodeFroces Round 438C. 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 Round #438 868C Qualification Rounds
- Codeforces Round #438 C Qualification Rounds(暴力+位运算)
- Codeforces 868C Qualification Rounds【思维】
- C. Qualification Rounds
- problem/868/C Qualification Rounds 思维题 状态压缩 暴力枚举
- CF868C:Qualification Rounds(思维)
- Codeforces Round #438 (Div. 1 + Div. 2 combined) C. Qualification Rounds
- Codeforces Round #438 C.Qualification Rounds(状态压缩再枚举状态)
- Codeforces 868 C Qualification Rounds
- codeforces 868C Qualification Rounds
- CF2017.10.5 C. Qualification Rounds
- HDU5583 Kingdom of Black and White
- Object浅拷贝、深拷贝
- jeesite的重定向参数repage
- 洛谷 P1513 绕钉子的长绳子
- 技术博客写作计划(持续更新)
- CodeFroces Round 438C. Qualification Rounds(思维题)
- Mac 下使用ll命令
- VIJOS-P1571 笨笨的导弹攻击
- 浏览器Request Header和Response Header的内容
- 爬虫笔记(10/6)-------多开技能
- 断言
- Java对象初始化详解
- 静态包含和动态包含的区别
- c++基础杂烩