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 ...
随机推荐
- Android开发 更改返回button的图标
非常多的Android应用左上角都有返回button 在默认的情况下 ADT会默认给一个返回图标 而作为开发需求 非常多都要求定制一个新的图标 在Android的站点上 发现了2种能够更改的方法 1. ...
- SOLOWHEEL - 电动独轮车 - SOLOWHEEL俱乐部聚会活动火热报名中
SOLOWHEEL - 电动独轮车 - SOLOWHEEL俱乐部聚会活动火热报名中 SOLOWHEEL俱乐部聚会活动火热报名中
- POJ 1018 【枚举+剪枝】.cpp
题意: 给出n个工厂的产品参数带宽b和价格p,在这n个工厂里分别选1件产品共n件,使B/P最小,其中B表示n件产品中最小的b值,P表示n件产品p值的和. 输入 iCase n 表示iCase个样例n个 ...
- hdu2222Keywords Search (特里)
Problem Description In the modern time, Search engine came into the life of everybody like Google, B ...
- atitit.java方法属性赋值and BeanUtils 1.6.1 .copyProperty的bug
atitit.java分配给属性值方法and BeanUtils 1.6.1 .copyProperty的bug 1. core.setProperty(o, "materialId&quo ...
- ThreadSafeClientConnManager的20个例子
Java Code Examples for org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager The following are ...
- python手记(52)
python将信息加密进图片 从图片中解密信息 >>> runfile(r'K:\testpro\test1.py', wdir=r'K:\testpro') http://blog ...
- 《JavaScript设计模式与开发实践》读书笔记之代理模式
1.代理模式 代理模式是为一个对象提供一个代用品或占位符,以便控制对它的访问 1.1 一般的图片加载 var myImage=(function () { var imgNode=document.c ...
- 关于使用X-UA-Compatible来设置IE浏览器兼容模式
原文地址:http://www.cnblogs.com/nidilzhang/archive/2010/01/09/1642887.html 前言 为了帮助确保你的网页在所有未来的IE版本都有一致的外 ...
- poj1655 Balancing Act 找树的重心
http://poj.org/problem? id=1655 Balancing Act Time Limit: 1000MS Memory Limit: 65536K Total Submis ...