dp : 区间dp
ProLightsfxjh
这个作者很懒,什么都没留下…
展开
-
UVA 1626 Brackets sequence dp:经典&&类似于三角剖分
Let us define a regular brackets sequence in the following way: Empty sequence is a regular sequence. If S is a regular sequence, then (S) and [S] are both regular sequences. If A and B are regular sequences, then AB is a regular sequence. For example, all原创 2016-02-27 22:34:26 · 984 阅读 · 0 评论 -
UVa 11400 Lighting System Design dp : 线性结构上dp LIS
You are given the task to design a lighting system for a huge conference hall. After doing a lot of calculation and sketching, you have figured out the requirements for an energy-efficient design that can properly illuminate the entire hall. According to y原创 2016-02-25 20:25:23 · 1117 阅读 · 0 评论 -
UVa 11584 Partitioning by Palindromes dp : 线性结构上dp LIS
A partition of a sequence of characters is a list of one or more disjoint non-empty groups of consecutive characters whose concatenation yields the initial sequence. For example, (‘race’, ‘car’) is a partition of ‘racecar’ into two groups. Given a sequence原创 2016-02-26 19:16:53 · 830 阅读 · 0 评论 -
UVa 10003 Cutting Sticks dp : 线性dp triangulation三角剖分
You have to cut a wood stick into pieces. The most affordable company, The Analog Cutting Machinery, Inc. (ACM), charges money according to the length of the stick being cut. Their procedure of work requires that they only make one cut at a time. It is eas原创 2016-02-28 11:29:16 · 797 阅读 · 0 评论 -
UESTC 1131 男神的礼物 dp:最优矩阵链乘&&triangulation&&双dp
Lweb学长是集训队里公认的男神。有一天他要给美美的学姐姐准备礼物。 Lweb学长可是会魔法的哟。为了准备一份礼物,男神要加工n份材料。每一次只能加工相邻的材料。 当男神加工两个魔法值为a,b的材料,男神都要消耗a*b的体力,同时在这个地方合成出魔法值(a+b)%100的材料。 男神为了能节省体力来完成他的礼物。想找聪明的你帮他算一算他所要花费的最小体力。原创 2016-02-28 16:55:13 · 1210 阅读 · 0 评论 -
2016 UESTC Training for Dynamic Programming D - 柱爷的恋爱 区间dp、记忆化搜索
记忆化搜索 dp[a, b] 表示 [a, b) 内的方案数; 如果line[a] 要去掉, 则直接转移 dp[a, b] = dfs(a+1, b); 如果line[a]不去掉的, 那么如果line[a] 是'('就去找line[i] == ')',如果'['就找line[i] == ']', 找到一个算一个, 同时 [a+1, i) 和 [i+1, b)也要合法序列 然后dfs(a + 1, i) * dfs(i+1, b); 然后调用dfs(0,n) 就好了,找出[0,n) 内的方案数: 复杂度O(n原创 2016-05-17 11:45:47 · 1137 阅读 · 0 评论 -
Codeforces Round #367 (Div. 2) C. Hard problem 朴素dp、线性dp
状态定义: LL dp[maxn][2]; dp[i][0] 表示前 i 个字符串 按字典序排列, 且第 i 个字符串不翻转 的 最小花费 dp[i][1] 表示前 i 个字符串 按字典序排列, 且第 i 个字符串翻转 的 最小花费 初始化: dp[i][0] = dp[i][1] = INF 边界: i == 0, dp[i][0] = 0, dp[i][1] = c[i]; 状态转移方程: if(dp[i - 1][0] != INF) if(s[i] >= s[i - 1]) dp[i][0原创 2016-09-09 02:00:51 · 829 阅读 · 0 评论 -
2016 ACM/ICPC Asia Regional Shenyang Online 1009 QSC and Master 区间dp
状态定义: dp[i][j][u] u == 1 时表示 当端点 i, j 进行合并时(取出 val[i] 、 val[j] 时) 或 i < k < k+1 < j, key[i] 和 key[k] 可以合并 且key[k+1] 和 key[j]合并的, 区间 [i, j]内的最大价值; u == 0 时表示 当端点 i, j 不进行合并时(不取出 val[i] 、 val[j] 时) 的 区间 [i, j]内的最大价值; 初始化:全部初始化为 0;边界: 当 j - i == 1 时 如果可以合并原创 2016-09-20 01:22:15 · 1400 阅读 · 0 评论