哦,我没做

#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 _(:зゝ∠)_ 哈哈的更多相关文章

  1. hdu 4915 Parenthese sequence(模拟)2014多培训学校5现场

    Parenthese sequence                                                                     Time Limit: ...

  2. HDU 4915 Parenthese sequence

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4915 解题报告:从前往后遍历一次,每次判断')'的数目是不是满足 n < (i +1)/ 2,从 ...

  3. hdu 4915 Parenthese sequence 多校第五场

    推断一个序列是否是有效是简单的. 可是推断序列是不是有多个解会出问题. 那么从i=0 ~l 假设读到问号,推断该问号成为(能否有效,该问号为)是否有效. 假设都有效,则必有多个解. 假设都无效,则无解 ...

  4. 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 ...

  5. HDU 4937 Lucky Number 规律题_(:зゝ∠)_

    把全部合法的进制打出来会发现合法的进制都是在 n/3 n/4 n/5的边上 然后暴力边上的进制数.. #include <cstdio> #include <set> type ...

  6. HDU 4839 The Game of Coins _(:зゝ∠)_

    The Game of Coins mark: #include"cstdio" #include"iostream" #include"queue& ...

  7. HDU 4876 ZCC loves cards _(:зゝ∠)_ 随机输出保平安

    GG,,,g艹 #include <cstdio> #include <iostream> #include <algorithm> #include <st ...

  8. UVALive 6663 Count the Regions 离散+bfs染色_(:зゝ∠)_

    题目链接:option=com_onlinejudge&Itemid=8&page=show_problem&problem=4675">点击打开链接 gg.. ...

  9. 转:HIBERNATE一些_方法_@注解_代码示例---写的非常好

    HIBERNATE一些_方法_@注解_代码示例操作数据库7步骤 : 1 创建一个SessionFactory对象 2 创建Session对象 3 开启事务Transaction : hibernate ...

随机推荐

  1. 端口映射工具 redir/socat/xinetd - 运维技术 - 开源中国社区

    端口映射工具 redir/socat/xinetd - 运维技术 - 开源中国社区 端口映射工具 redir/socat/xinetd    10人收藏此文章, 我要收藏 发表于3天前(2013-08 ...

  2. 阿里云免费试用之体验——阿里云serverECS试用心得

    自上次參加了阿里云的开发人员大会回来 心里就一直惦记着阿里云 由于曾经各种各样什么的server也用了不少 年前開始接触阿里云 一直没有给予很多其它的关注 參加了这次的开发人员大会后 就想更进一步的了 ...

  3. gulp快速入门

    gulp快速入门 因为之前一直有人给我推荐gulp,说他这里好哪里好的.实际上对我来说够用就行.grunt熟悉以后实际上他的配置也不难,说到效率的话如果真是要完整打包上线也不在乎那么几秒时间,对于项目 ...

  4. Inno Setup打包添加和去除管理员权限

    原文:Inno Setup打包添加和去除管理员权限 添加管理员权限 1.在[Setup]节点添加 PrivilegesRequired=admin 2.进入安装目录,找到文件SetupLdr.e32, ...

  5. (转)一篇很不错的介绍Eclipse插件Menu及其扩展点的文章

    原文在:http://tech.ddvip.com/2010-04/1271054623150507.html 菜单是各种软件及开发平台会提供的必备功能,Eclipse 也不例外,提供了丰富的菜单,包 ...

  6. malformed or corrupted AST file。。。module file out of date&#39;

    今天打开了曾经用的一个项目,(曾经的程序是对的)弹出了两个红框 malformed or corrupted AST file...module file out of date'. 这种结构. 解决 ...

  7. SlidingMenu开源项目滑动界面的实现总结

    先上图 须要准备的是先得在GitHub上下载ActionBarSherlock-master.zip,和SlidingMenu-master.zip这两个开源文件,然后解压这两个包,SlidingMe ...

  8. U5首次登录

    1.在Llinx中,大小写字母是不一样的东西. 2.date可以查看日期,date的正确格式是:date +%Y/%m/%d/%H/%M(左边这句话所想表达的意思是年的字母必须为大写,月的必须为小写. ...

  9. Redis11种Web应用场景

    Redis的一个非常大优点就是能够不用整个转入到这个数据库,而是能够沿用之前的MySQL等数据库,而仅在一些特定的应用场景通过Redis的特性提高效率.本文列出了11个这种Web应用场景,如显示最新的 ...

  10. hdu1025 Constructing Roads In JGShining&#39;s Kingdom (nlogn的LIS)

    题目链接 第一次写nlogn复杂度的LIS,纪念一下. 题目意思是说.有两条平行线.两条平行线都有n个城市,都是从左到右标记为1--n,一条线上是富有城市,一个是贫穷城市.输入n.接下来有n行,p,r ...