HDU 4915 Parenthese sequence _(:зゝ∠)_ 哈哈
哦,我没做
#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;
}
HDU 4915 Parenthese sequence _(:зゝ∠)_ 哈哈的更多相关文章
- hdu 4915 Parenthese sequence(模拟)2014多培训学校5现场
Parenthese sequence Time Limit: ...
- HDU 4915 Parenthese sequence
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4915 解题报告:从前往后遍历一次,每次判断')'的数目是不是满足 n < (i +1)/ 2,从 ...
- hdu 4915 Parenthese sequence 多校第五场
推断一个序列是否是有效是简单的. 可是推断序列是不是有多个解会出问题. 那么从i=0 ~l 假设读到问号,推断该问号成为(能否有效,该问号为)是否有效. 假设都有效,则必有多个解. 假设都无效,则无解 ...
- hdu 4915 Parenthese sequence--2014 Multi-University Training Contest 5
主题链接:http://acm.hdu.edu.cn/showproblem.php?pid=4915 Parenthese sequence Time Limit: 2000/1000 MS (Ja ...
- HDU 4937 Lucky Number 规律题_(:зゝ∠)_
把全部合法的进制打出来会发现合法的进制都是在 n/3 n/4 n/5的边上 然后暴力边上的进制数.. #include <cstdio> #include <set> type ...
- HDU 4839 The Game of Coins _(:зゝ∠)_
The Game of Coins mark: #include"cstdio" #include"iostream" #include"queue& ...
- HDU 4876 ZCC loves cards _(:зゝ∠)_ 随机输出保平安
GG,,,g艹 #include <cstdio> #include <iostream> #include <algorithm> #include <st ...
- UVALive 6663 Count the Regions 离散+bfs染色_(:зゝ∠)_
题目链接:option=com_onlinejudge&Itemid=8&page=show_problem&problem=4675">点击打开链接 gg.. ...
- 转:HIBERNATE一些_方法_@注解_代码示例---写的非常好
HIBERNATE一些_方法_@注解_代码示例操作数据库7步骤 : 1 创建一个SessionFactory对象 2 创建Session对象 3 开启事务Transaction : hibernate ...
随机推荐
- hdu3001(状压dp)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=3001 题意:n 个城市已经 m 条路 以及对应路费 c,要求遍历所有城市最少的路费,每个城市不能超过2 ...
- 不可不知的DIP、IoC、DI以及IoC容器
面向对象设计(OOD)有助于我们开发出高性能.易扩展以及易复用的程序.当中.OOD有一个重要的思想那就是依赖倒置原则(DIP),并由此引申出IoC.DI以及Ioc容器等概念. 本文首先用实例阐述四个概 ...
- TMS320F28335项目开发记录9_28335中断系统
28335中断系统 1.中断系统 在这里我们要十分清楚DSP的中断系统. C28XX一共同拥有16个中断源,当中有2个不可屏蔽的中断RESET和NMI.定时器1和定时器2分别使用中断13和14.这样还 ...
- cocoa动态方法决议及消息转发
假设给一个对象发送不能响应的消息,同一时候又没有进行动态方法决议,又没实现消息转发,那么就会引发以下的crash信息 2014-07-30 15:47:54.434 MethodNotFind[171 ...
- extjs_11_mvc模式
1.非mvc模式 watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvYWRhbV93enM=/font/5a6L5L2T/fontsize/400/fill/I ...
- HDU - 1588 Gauss Fibonacci (矩阵高速幂+二分求等比数列和)
Description Without expecting, Angel replied quickly.She says: "I'v heard that you'r a very cle ...
- HGE基础教程
作者:寰子 来源:http://www.hgechina.com/前言: 写道: 无意中发现了hge中文社区,听朋友介绍,认识了hge,然后开始对它进行研究,并使用hge开始制作游戏. 因为我所得的资 ...
- 安卓SDK更新host文件地址
之前在安装jdk时,安装进度一直很缓慢,在更新这个(两个任选,都有效)host文件地址后,瞬间就可以了. 203.208.46.146 dl.google.com 203.208.46.146 dl- ...
- thinkphp框架的相关总结
参考链接地址:http://gongwen.sinaapp.com/article-205.html 1. 模板中不能使用的标签 {$content} {$i} 2. If标签 如: <if c ...
- Service组件 总结 + 绑定理Service三种实现方式 Messager + Binder + AIDL
在Android中进程按优先级可以分为五类,优先级从高到低排列: - 前台进程 该进程包含正在与用户进行交互的界面组件,比如一个Activity - 可视进程 该进程中的组件虽然没有和用户交互,但是仍 ...