POJ 1029 False coin
来源:互联网 发布:广播地址的mac 编辑:程序博客网 时间:2024/04/29 08:38
类似于POJ 1013,略有变化
#include <cstdio>#include <vector>using namespace std;int n, k, w[1005];vector<int> vec_l[105], vec_r[105];char op[105];bool judge(){ for(int i = 0; i < k; i++) { int sum_l = 0, sum_r = 0; for(int j = 0; j < vec_l[i].size(); j++) sum_l += w[vec_l[i][j]]; for(int j = 0; j < vec_r[i].size(); j++) sum_r += w[vec_r[i][j]]; if(sum_l > sum_r && op[i] != '>') return false; if(sum_l == sum_r && op[i] != '=') return false; if(sum_l < sum_r && op[i] != '<') return false; } return true;}int solve(){ int ans = 0; for(int i = 1; i <= n; i++) w[i] = 1; for(int i = 1; i <= n; i++) { w[i] = 2; if(judge()) { if(ans == 0) ans = i; else return 0; w[i] = 1; continue; } w[i] = 0; if(judge()) { if(ans == 0) ans = i; else return 0; } w[i] = 1; } return ans;}int main(){ scanf("%d%d", &n, &k); { for(int i = 0; i < k; i++) vec_l[i].clear(), vec_r[i].clear(); for(int i = 0; i < k; i++) { int num, t; scanf("%d", &num); for(int j = 0; j < num; j++) { scanf("%d", &t); vec_l[i].push_back(t); } for(int j = 0; j < num; j++) { scanf("%d", &t); vec_r[i].push_back(t); } char ch[2]; scanf("%s", ch); op[i] = ch[0]; } printf("%d\n", solve()); } return 0;}
0 0
- poj 1029 False Coin
- POJ 1029 False coin
- poj 1029 False coin
- poj 1029 False coin
- poj 1029 False coin
- POJ-1029-False coin
- POJ 1029 False coin
- False coin - POJ 1029
- POJ 1029 False coin
- POJ 1029-False coin
- POJ 1029 False coin
- POJ 1029--False coin
- POJ 1029 False coin 笔记 模拟
- POJ 1029 False coin 找假币 模拟
- poj 1028 False coin
- 1029 False coin
- 1029 False coin
- 1029 False coin
- immutablejs
- WINDOWS 7远程连接终极配置方法汇总
- 5.9 练习
- 《从0到1》读书散记一
- tomcat启动startup后,一闪而过
- POJ 1029 False coin
- Linux的加密认证功能以及openssl详解
- stm32 开始之路,第一篇,写一些闲话。
- leetcode之Symmetric Tree
- java图形处理-Java 2D
- UOJ UER#5 A 万圣节的南瓜灯
- 输出频率最高的那个单词
- Ctags自动补全(不使用grep)
- 大数加法