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 ...
随机推荐
- 【Struts2学习笔记(11)】对action的输入校验和XML配置方式实现对action的全部方法进行输入校验
在struts2中,我们能够实现对action的全部方法进行校验或者对action的指定方法进行校验. 对于输入校验struts2提供了两种实现方法: 1. 採用手工编写代码实现. 2. 基于XML配 ...
- 解决com.ibatis.sqlmap.client.SqlMapException: There is no statement named in this SqlMap
com.ibatis.sqlmap.client.SqlMapException: There is no statement named in this SqlMap. 可能存在3种情况: 1.在x ...
- hadoop每个家庭成员
本文没有提到的原则.谈论hadoop项目周边,它的作用. hadoop这个词已经流行了很多年.大数据的记载会认为hadoop,然后hadoop的作用是什么呢? 官方定义:hadoop是一个开发和执行处 ...
- 什么是Spring?Spring是什么?
Spring概述: Spring是一个开源框架,是为了解决企业应用程序开发复杂性而开发的. 从简单性.可測试性和松耦合的角度而言,不论什么java应用都能够从Spring中受益. 简而言之,Sprin ...
- 跟我extjs5(38--单个模块的设计[6获得模块列表数据])
跟我extjs5(38--单个模块的设计[6获得模块列表数据]) 在程序的前一个表以及,据的执行过程. 在菜单中选择 "系统管理"--"模块分组" ...
- windows服务的创建、安装和调试
1.创建 windows服务 项目 文件 -> 新建项目 -> 已安装的模板 -> Visual C# -> windows ,在右侧窗口选择"windows 服 ...
- ubuntu终端方向键不能用(主机名不显示)问题的解决
sudo gedit /etc/passwd 在/etc/passwd中改动该用户相应的shell:/bin/sh改为/bin/bash就可以解决该问题
- DIV水平和垂直居中的实现
在div的宽度和高度固定的情况下,实现div水平和垂直居中普遍采用如下的方式: <!DOCTYPE html> <html> <head> <style ty ...
- UVA 11490 - Just Another Problem(数论)
11490 - Just Another Problem option=com_onlinejudge&Itemid=8&page=show_problem&category= ...
- Bitmap
Bitmap篇 在前一篇中介绍了使用API做Distinct Count,但是计算精确结果的API都较慢,那有没有能更快的优化解决方案呢? 1. Bitmap介绍 <编程珠玑>上是这样 ...