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题目需要记录到底是怎样得到结果的,不一定了可以通过记录信息直接得到,可以选择数组记录其他有用信息,可以写递归来找出最后的答案。*/ |
相关文章
- poj 1088 滑雪(区间dp+记忆化搜索)
- POJ3280 - Cheapest Palindrome(区间DP)
- IOI 98 (POJ 1179)Polygon(区间DP)
- POJ 2955 括号匹配,区间DP
- POJ 1179 - Polygon - [区间DP]
- POJ1651:Multiplication Puzzle(区间DP)
- POJ 2955 Brackets (区间dp入门)
- poj 1141 Brackets Sequence ( 区间dp+输出方案 )
- Cheapest Palindrome [POJ3280] [区间DP] [经典]
- [poj3280]Cheapest Palindrome_区间dp