状态表示方法:d[ i ][ j ]表示的是一条序列的开始和结束;
状态定义:d[ i ][ j ]表示字串s[ i~j ] 需要添加的数量。
#include
#include
#include
using namespace std;
int n;
char s[105];
int d[105][105];
bool match(char ch1,char ch2)
{
if(...
分类:
其他好文 时间:
2014-08-14 16:46:58
阅读次数:
239
我只能说这道题和上一道动态规划的问题真的是太像了,连方法也一模一样
确实,计数也需要存状态,计数也是需要动规的。
此时d【i】【j】表示的状态是s【i~j】的序列中有多少 不规则 的括号。
#include
#include
#include
using namespace std;
int n;
char s[105];
int d[105][105];
bool ma...
分类:
其他好文 时间:
2014-08-14 16:46:08
阅读次数:
164
不要因为走的太远而忘记我们为什么出发[问题描述]Given a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid.The brackets mu...
分类:
其他好文 时间:
2014-08-14 01:00:57
阅读次数:
160
Given a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid.The brackets must close in the correct ...
分类:
其他好文 时间:
2014-08-10 15:23:20
阅读次数:
215
Brackets SequenceTime Limit: 1000MSMemory Limit: 65536KTotal Submissions: 25132Accepted: 7083Special JudgeDescriptionLet us define a regular brackets ...
分类:
其他好文 时间:
2014-08-07 18:30:01
阅读次数:
196
问题:The brackets must close in the correct order,"()"and"()[]{}"are all valid but"(]"and"([)]"are not.,判断符合条件的符号([])也符合分析:遇到左边符号进栈,右边符号就将栈顶出栈,若和当前遍历的符号...
分类:
其他好文 时间:
2014-08-06 21:44:02
阅读次数:
206
Brackets Sequence
Time Limit: 1000MS
Memory Limit: 65536K
Total Submissions: 25087
Accepted: 7069
Special Judge
Description
Let us define a regular brackets seq...
分类:
其他好文 时间:
2014-08-06 10:29:51
阅读次数:
352
题意:用最少的括号将给定的字符串匹配,输出最优解。可能有空行。思路:dp。dp[i][j]表示将区间i,j之间的字符串匹配需要的最少括号数,那么如果区间左边是(或[,表示可以和右边的字符串匹配,枚举中间断点k,如果str[i]==str[k]则dp[i][j]=min(dp[i][j],dp[i+1...
分类:
其他好文 时间:
2014-08-05 13:46:00
阅读次数:
270
Description
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....
分类:
其他好文 时间:
2014-07-30 20:44:34
阅读次数:
267
Problem StatementWe have three types of brackets: "()", "[]", and "{}". We are now interested in some special strings. A string is special if all the ...
分类:
其他好文 时间:
2014-07-29 12:41:06
阅读次数:
187