HDU 4915 Parenthese sequence _(:зゝ∠)_ 呵呵
来源:互联网 发布:阿里云 centos7 mysql 编辑:程序博客网 时间:2024/05/22 07:00
呵呵不是我做的
#include <cstdio>#include <cstring>#include <algorithm>const int N = 1000000 + 10;char s[N];int d[N], num[N];int main() { while (~scanf("%s", s)) { memset(num, 0, sizeof num); int len = strlen(s); int f = 1, v = 0; for (int i = 0; i < len; ++i) { if (s[i] == '(' || s[i] == '?') ++ v; else -- v; d[i] = v; if (v < 0) { f = 0; break; } } if ((len & 1) || (d[len - 1] & 1)) f = 0; else if (f && d[len - 1] != 0) { for (int i = len - 2; i >= 0; --i) d[i] = std::min(d[i], d[i + 1]); v = d[len - 1] / 2; int cnt = 0; for (int i = 0; i < len && cnt != v; ++i) { if (s[i] != '?') continue; if (d[i] - 2 * (cnt + 1) >= 0) num[i] = ++cnt; } if (cnt != v) { f = 0; } else { int pre = 1; for (int i = 0; i < len && f != 2; ) { if (num[i] != pre) ++ i; else { int j; for (j = i + 1; j < len; ++j) { if (num[j] == pre + 1) break; if (s[j] != '?') continue; if (d[j] - pre * 2 >= 0) { f = 2; break; } } i = j; ++ pre; } } } } if (f == 0) puts("None"); else if (1 == f) puts("Unique"); else puts("Many"); } return 0;}
0 0
- HDU 4915 Parenthese sequence _(:зゝ∠)_ 呵呵
- HDU 4915 Parenthese sequence
- hdu 4915 Parenthese sequence
- hdu 4915 Parenthese sequence
- HDU 4915 Parenthese sequence
- HDU-4915-Parenthese sequence
- hdu 4915 Parenthese sequence
- HDU 4915 Parenthese sequence
- hdu 4915 Parenthese sequence(高效)
- 【HDU】4915 Parenthese sequence 贪心
- HDU 4915 Parenthese sequence DP
- HDU 4915 Parenthese sequence(瞎搞题)
- hdu 4915 Parenthese sequence (贪心+模拟)
- hdu 4915 Parenthese sequence(贪心,模拟)
- hdu 4915 Parenthese sequence (贪心+模拟)
- 【HDOJ 4915】Parenthese sequence
- HDOJ 4915 Parenthese sequence
- hdu 4915 Parenthese sequence 多校第五场
- 判断字符串是否为数字
- C2 Debug设置
- eclipse中将代码中某个相同的内容全部替换
- hd 2040 亲和数
- 设计模式7—Prototype设计模式
- HDU 4915 Parenthese sequence _(:зゝ∠)_ 呵呵
- 批量创建用户和邮箱
- 《有点失望》的经过及其背后意义
- 混合语言的游戏开发系统架构
- 《编程之美: 求二叉树中节点的最大距离》的另一个解法
- 解构Unity的腳本物件模型
- 两条像面试用的编程问题,和我的囧事
- 史上最强女游戏程序员
- 12年前的作品──《美绿中国象棋》制作过程及算法简介