区间DP POJ 1141 Brackets Sequence
|
Brackets Sequence
Description Let us define a regular brackets sequence in the following way:
1. Empty sequence is a regular sequence. For example, all of the following sequences of characters are regular brackets sequences: (), [], (()), ([]), ()[], ()[()] And all of the following character sequences are not: (, [, ), )(, ([)], ([(] Some sequence of characters '(', ')', '[', and ']' is given. You are to find the shortest possible regular brackets sequence, that contains the given character sequence as a subsequence. Here, a string a1 a2 ... an is called a subsequence of the string b1 b2 ... bm, if there exist such indices 1 = i1 < i2 < ... < in = m, that aj = bij for all 1 = j = n. Input The input file contains at most 100 brackets (characters '(', ')', '[' and ']') that are situated on a single line without any other characters among them.
Output Write to the output file a single line that contains some regular brackets sequence that has the minimal possible length and contains the given sequence as a subsequence.
Sample Input ([(] Sample Output ()[()] /*对于DP题目需要记录到底是怎样得到结果的,不一定了可以通过记录信息直接得到,可以选择数组记录其他有用信息,可以写递归来找出最后的答案。*/ |
||||||||||
区间DP POJ 1141 Brackets Sequence的更多相关文章
- POJ 1141 Brackets Sequence(区间DP, DP打印路径)
Description We give the following inductive definition of a “regular brackets” sequence: the empty s ...
- POJ 1141 Brackets Sequence (区间DP)
Description Let us define a regular brackets sequence in the following way: 1. Empty sequence is a r ...
- poj 1141 Brackets Sequence 区间dp,分块记录
Brackets Sequence Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 35049 Accepted: 101 ...
- POJ 1141 Brackets Sequence(括号匹配二)
题目链接:http://poj.org/problem?id=1141 题目大意:给你一串字符串,让你补全括号,要求补得括号最少,并输出补全后的结果. 解题思路: 开始想的是利用相邻子区间,即dp[i ...
- POJ 1141 Brackets Sequence
Brackets Sequence Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 29502 Accepted: 840 ...
- poj 1141 Brackets Sequence (区间dp)
题目链接:http://poj.org/problem?id=1141 题解:求已知子串最短的括号完备的全序列 代码: #include<iostream> #include<cst ...
- poj 1141 Brackets Sequence(区间DP)
题目:http://poj.org/problem?id=1141 转载:http://blog.csdn.net/lijiecsu/article/details/7589877 定义合法的括号序列 ...
- poj 1141 Brackets Sequence ( 区间dp+输出方案 )
http://blog.csdn.net/cc_again/article/details/10169643 http://blog.csdn.net/lijiecsu/article/details ...
- POJ 1141 Brackets Sequence(DP)
题目链接 很早 很早之前就看过的一题,今天终于A了.状态转移,还算好想,输出路径有些麻烦,搞了一个标记数组的,感觉不大对,一直wa,看到别人有写直接输出的..二了,直接输出就过了.. #include ...
随机推荐
- webgote的例子(3)Sql注入(SearchPOST)
Sql注入(Search/POST) (本章内容):post的方式进行注入 今天来讲一下sql注入的另一个例子(post) 上一个用的是get请求的方法将我们的参数传到服务器进行执行 上图中的标红是需 ...
- OTA之流式更新及shell实现
在OTA升级时,需要从网络下载OTA包,并写到flash上的对应分区中. 最简单的方式是将下载与更新分离,先将完整的数据包下载到本地,再将本地的OTA包更新到flash上.方便可靠. 但这种方式的问题 ...
- [转载]锁无关的(Lock-Free)数据结构
锁无关的(Lock-Free)数据结构 在避免死锁的同时确保线程继续 Andrei Alexandrescu 刘未鹏 译 Andrei Alexandrescu是华盛顿大学计算机科学系的在读研究生,也 ...
- php判断是手机还是pc访问从而走不同url
<?php header("Content-type:text/html;charset=utf-8"); function is_mobile(){ $user_agent ...
- web项目更改文件后缀,隐藏编程语言
从Java EE5.0开始,<servlet-mapping>标签就可以配置多个<url-pattern>.例如可以同时将urlServlet配置一下多个映射方式: <s ...
- 网页查看源码中<div>的含义
代码如下: /** HTML转义 **/ String s = HtmlUtils.htmlEscape("<div>hello world</div><p&g ...
- CRM 业务
1. 创建CRM项目 引入插件 创建数据库 from django.db import models from django.db import models class Department(mod ...
- fastdfs5.11+centos7.2 按照部署(一)【转载】
1.绪论 最近要用到fastDFS,所以自己研究了一下,在搭建FastDFS的过程中遇到过很多的问题,为了能帮忙到以后搭建FastDFS的同学,少走弯路,与大家分享一下.FastDFS的作者淘宝资深架 ...
- java SE :文件基本处理 File、FileFilter、FileNameFilter
File 对目录及文件的创建.重命名.删除.文件列表.判断是否存在 构造函数 // 完整的目录或文件路径 public File(String pathname) //父级目录/文件路径+子级目 ...
- 【51nod】1340 地铁环线
今天头非常疼,躲在家里没去机房 反正都要颓废了,然后花了一上午研究了一下这道神题怎么做-- 题解 首先我们发现,如果我们设\(dis[i]\)为从\(0\)节点走到\(i\)节点的距离 那么题目中给出 ...