码迷,mamicode.com
首页 >  
搜索关键字:brackets    ( 439个结果
Codeforces 380C. Sereja and Brackets【线段树】
题目大意: 给出一串括号,有m个查询(包含a,b)问区间[a,b]之间有多少个匹配的括号 做法: 处理两个数组r[i](代表从1到i之间有多少个已匹配的右括号),l[i](代表从1到i之间有多少个没有匹配的左括号)。我们要算[a,b]之间的匹配的括号数,首先用r[b]-r[a-1],但是遮掩更有可能a到b之间的右括号是在[1,a-1]之间被匹配的,那么再减去l[a-1],但是减去的这一部分中...
分类:其他好文   时间:2014-08-30 08:48:09    阅读次数:210
【LeetCode】- Valid Parentheses(有效的括号)
[ 问题: ] Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. 直译:给定一个字符串,该串包含字符'(', ')', '{', '}', '[', ']', 请判断它是不是有效的 The brackets must close in the correct order, "()" and "()[]{}" are al...
分类:其他好文   时间:2014-08-29 16:11:48    阅读次数:195
ural Brackets Sequence (dp)
http://acm.timus.ru/problem.aspx?space=1&num=1183 很经典的问题吧,看的黑书上的讲解。 设dp[i][j]表示i到j括号合法需要的最少括号数。 共有四种情况: s[i]s[j]配对,dp[i][j] = min( dp[i][j] ,  dp[i-1][j+1] ); s[i] = '('或'[' dp[i][j] = min( d...
分类:其他好文   时间:2014-08-26 11:42:55    阅读次数:206
[LeetCode] Valid Parentheses
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the c...
分类:其他好文   时间:2014-08-25 13:04:24    阅读次数:139
leetcode 之 Longest Valid Parentheses
leetcode中和括号匹配相关的问题共有三个,分别是: Valid Parentheses   Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. The brackets m...
分类:其他好文   时间:2014-08-18 20:35:52    阅读次数:221
codeforces 149D - Coloring Brackets (区间dp)
题目大意: 给出一组合法的括号。 括号要么不涂颜色,要么就涂上红色或者绿色。 匹配的括号只能有一个有颜色。 两个相邻的括号不能有相同的颜色。 思路分析: 因为是一个合法的括号序列。 所以每个括号与之匹配的位置是一定的。 那么就可以将这个序列分成两个区间。 (L - match[L] )  (match[L]+1, R) 用递归先处理小区间,再转移大区间。 ...
分类:其他好文   时间:2014-08-17 17:04:42    阅读次数:206
POJ 1141 Brackets Sequence (区间dp 记录路径)
题目大意: 给出一种不合法的括号序列,要求构造出一种合法的序列,使得填充的括号最少。 思路分析: 如果只要求输出最少的匹配括号的数量,那么就是简单的区间dp dp[i][j]表示 i - j 之间已经合法了最少添加的括号数。 转移 就是 dp[i] [j] = min  (dp[i+1][j]+1 , dp[ i+ 1] [ k -1 ] + dp[k+1] [j] (i k 位...
分类:其他好文   时间:2014-08-17 15:38:22    阅读次数:222
ZOJ1463:Brackets Sequence(区间DP)
Let us define a regular brackets sequence in the following way: 1. Empty sequence is a regular sequence. 2. If S is a regular sequence, then (S) and [S] are both regular sequences. 3. If A an...
分类:其他好文   时间:2014-08-16 15:10:30    阅读次数:262
BNUOJ 1260 Brackets Sequence
Brackets SequenceTime Limit: 1000msMemory Limit: 65536KBThis problem will be judged onPKU. Original ID:114164-bit integer IO format:%lld Java class na...
分类:其他好文   时间:2014-08-15 22:25:49    阅读次数:283
POJ 2955 Brackets (区间dp)
题目大意: 两种括号匹配,求最长的匹配长度。 思路分析: 状态方程:dp [i][j] 表示区间 i ~ j 之间最长的匹配长度。 转移方程:dp [i][j]  = max (dp[i+1][j] , dp[i] [j-1 ] , dp[i+1][k-1] + dp[k+1][j] +2 (条件是i ,k 位置匹配)) #include #include #incl...
分类:其他好文   时间:2014-08-15 18:01:59    阅读次数:184
439条   上一页 1 ... 38 39 40 41 42 ... 44 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!