题目链接:https://vjudge.net/problem/LightOJ-1422 简单题意:参加n场舞会,编号为i的场次需要穿衣服i。衣服可以叠着穿,只看最外层的衣服,而且脱下后不能再穿。求最少要买的衣服数 不太能想到这是个区间dp吧,而且方程和以前做的简单区间dp(能量项链,poj2955 ...
分类:
其他好文 时间:
2020-07-04 23:04:07
阅读次数:
91
POJ2955 Brackets 题目链接:https://vjudge.net/problem/POJ-2955 题意:求最长的合法括号子序列长度 思路: 基础的区间DP问题。用f[i][j]表示第i到第j区间内的最长合法括号子序列长度。 首先要进行预处理: 如果当前区间 [l,r] 的左端点和右 ...
分类:
其他好文 时间:
2020-04-26 21:05:13
阅读次数:
51
We give the following inductive definition of a “regular brackets” sequence: the empty sequence is a regular brackets sequence, if s is a regular brac ...
分类:
其他好文 时间:
2020-03-18 13:48:36
阅读次数:
54
我们知道一个的是0,因此先初始化两个长度的时候 之后运用区间dp的思想,如果s[l]和s[r]满足是一对,那么先由内部更新 之后我们枚举断点,计算相加的情况 #include<iostream> #include<algorithm> #include<cstdio> #include<cmath> ...
分类:
其他好文 时间:
2020-02-18 16:41:24
阅读次数:
70
题目链接:http://poj.org/problem?id=2955【题目描述】《规则的括号序列》我们定义一个字符串序列为“规则的括号序列”当且仅当它满足如下条件:1、空字符串是规则的括号序列;2、如果字符串 s 是一个规则的括号序列,那么 (s) 和 [s] 也是规则的括号序列;3、如果字符串 ...
分类:
其他好文 时间:
2019-06-07 20:55:51
阅读次数:
100
POJ2955 匹配则加一,不需要初始化 1 //#include<bits/stdc++.h> 2 #include<iostream> 3 #include<cstdio> 4 #include<algorithm> 5 #include<vector> 6 #include<cstring> ...
分类:
其他好文 时间:
2018-10-19 20:20:11
阅读次数:
157
题目:http://poj.org/problem?id=2955 区间DP。 代码如下: ...
分类:
其他好文 时间:
2018-02-11 23:39:41
阅读次数:
193
Description We give the following inductive definition of a “regular brackets” sequence: the empty sequence is a regular brackets sequence, if s is a ...
分类:
其他好文 时间:
2017-09-14 23:27:39
阅读次数:
171
解题关键:了解转移方程即可。 转移方程:$dp[l][r] = dp[l + 1][r - 1] + 2$ 若该区间左右端点成功匹配。然后对区间内的子区间取max即可。 ...
分类:
其他好文 时间:
2017-08-24 18:02:55
阅读次数:
120