![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
dp
日月火山
这个作者很懒,什么都没留下…
展开
-
宝岛地图(dp)
勇敢的水手们到达了一个小岛,在这个小岛上,曾经有海盗在这里埋下了一些宝藏。然而,我们的船快抛锚了,与此同时,船长发现藏宝图的一角被老鼠咬掉了一块。 藏宝图可以用一个n×m大小的矩形表示。矩形中的每一小块表示小岛中的一小块陆地(方块的边长为1米)。有一些方块表示的是海,这些块人是不能通过的。除了海不能走,其它的小方块都是可以行走的。在可行走区域里有一些小方块表示一些已知的地点。 另外原创 2017-07-21 11:42:19 · 1545 阅读 · 0 评论 -
最大m子段和
最大M子段和 51Nod - 1052 题意描述:给定数组a,长度为n。给定整数m,求不相交的m段字段和的最大值。 当m == 1 时:该问题就是最大子段和问题。 设dp[i]为以a[i]结尾的最大子段和,当我们考虑dp[i]的时候如果dp[i-1] > 0那么肯定把a[i]接在后面最优,否则,取a[i]最优。 得到 dp[i] = max(dp[i-1]+a[i]...原创 2018-11-04 22:06:19 · 1494 阅读 · 1 评论 -
Schrödinger's Knapsack(dp)
Schrödinger's KnapsackTime Limit: 1 Second Memory Limit: 65536 KBDreamGrid has a magical knapsack with a size capacity of called the Schrödinger's knapsack (or S-knapsack for short) and two type...原创 2018-04-08 13:57:12 · 486 阅读 · 0 评论 -
QSC and Master (区间dp)
QSC and MasterTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 832 Accepted Submission(s): 314Problem DescriptionEvery school has some legen...原创 2018-03-11 12:01:47 · 210 阅读 · 0 评论 -
历届试题 波动数列 (dp)
历届试题 波动数列 时间限制:1.0s 内存限制:256.0MB 提交此题 问题描述 观察这个数列: 1 3 0 2 -1 1 -2 …/* 思路:设第一个元素为a0:若想让最后和为s 则要满足 sum = a[0]+a[1]+...+a[n-1] = s 由于a[k] 是由 a[k-1] 通过+a或者-b得到的 所以任何 i < k 若a[i]都会对他产生影响 例如:若每次都是加...原创 2018-03-06 22:39:27 · 980 阅读 · 3 评论 -
Game of Connections HDU - 1134 (大数乘 + 记忆dp)
This is a small but ancient game. You are supposed to write down the numbers 1, 2, 3, ... , 2n - 1, 2n consecutively in clockwise order on the ground to form a circle, and then, to draw some straight原创 2017-11-10 18:19:12 · 283 阅读 · 0 评论 -
Arpa's weak amphitheater and Mehrdad's valuable Hoses CodeForces - 742D (分组背包)
Just to remind, girls in Arpa's land are really nice. Mehrdad wants to invite some Hoses to the palace for a dancing party. Each Hos has some weight wi and some beauty bi. Also each Hos may have so原创 2017-09-17 21:49:16 · 403 阅读 · 0 评论 -
Kefa and Dishes CodeForces - 580D (dp 状态压缩)
When Kefa came to the restaurant and sat at a table, the waiter immediately brought him the menu. There were n dishes. Kefa knows that he needs exactly m dishes. But at that, he doesn't want to orde原创 2017-09-25 20:09:41 · 383 阅读 · 0 评论 -
C. Ilya And The Tree(树形搜索+dp)
C. Ilya And The Tree time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Ilya is very fond of graphs, especiall原创 2017-08-30 17:05:43 · 400 阅读 · 0 评论 -
合法括号子段 51Nod - 1791 (栈+dp)
有一个括号序列,现在要计算一下它有多少非空子段是合法括号序列。 合法括号序列的定义是: 1.空序列是合法括号序列。 2.如果S是合法括号序列,那么(S)是合法括号序列。 3.如果A和B都是合法括号序列,那么AB是合法括号序列。 Input多组测试数据。 第一行有一个整数T(1 接下来T行,每一行都有一个括号序列,是一个由'('和')'组成的非空串。 所有输入的括号序列的原创 2017-08-23 21:58:39 · 583 阅读 · 0 评论 -
滑雪(dp 记忆化搜索)
Michael喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激。可是为了获得速度,滑的区域必须向下倾斜,而且当你滑到坡底,你不得不再次走上坡或者等待升降机来载你。Michael想知道载一个区域中最长底滑坡。区域由一个二维数组给出。数组的每个数字代表点的高度。下面是一个例子 1 2 3 4 5 16 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12原创 2017-08-15 20:42:39 · 395 阅读 · 0 评论 -
ycb的ACM进阶之路(背包优化)
ycb的ACM进阶之路 发布时间: 2017年5月22日 14:30 最后更新: 2017年5月22日 14:31 时间限制: 1000ms 内存限制: 128M 描述 ycb是个天资聪颖的孩子,他的梦想是成为世界上最伟大的ACMer。为此,他想拜附近最有威望的dalao为师。dalao为了判断他的资质,给他出了一个难题。dalao把他带到一个到处都是题的oj里对原创 2017-08-15 20:32:33 · 466 阅读 · 0 评论 -
codeforces(背包)
codeforces 发布时间: 2017年5月13日 22:40 最后更新: 2017年5月14日 16:39 时间限制: 1000ms 内存限制: 128M 描述 LYD loves codeforces since there are many Russian contests. In an contest lasting for T minutes t原创 2017-08-15 20:17:56 · 510 阅读 · 0 评论 -
51nod 1202 子序列个数(dp)
子序列的定义:对于一个序列a=a11,a22,......ann。则非空序列a'=ap1p1,ap2p2......apmpm为a的一个子序列,其中1 例如4,14,2,3和14,1,2,3都为4,13,14,1,2,3的子序列。对于给出序列a,有些子序列可能是相同的,这里只算做1个,请输出a的不同子序列的数量。由于答案比较大,输出Mod 10^9 + 7的结果即可。 Input第1行原创 2017-08-20 21:34:37 · 293 阅读 · 0 评论 -
Course Selection System ZOJ - 3956 (0,1背包变型)
There are n courses in the course selection system of Marjar University. The i-th course is described by two values: happiness Hi and credit Ci. If a student selectsm courses x1, x2, ..., xm, then h原创 2017-08-20 20:43:05 · 312 阅读 · 0 评论 -
Codeforces Round #427 (Div. 2)C. Star sky(dp)
C. Star sky time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The Cartesian coordinate system is set in the s原创 2017-08-01 12:58:40 · 280 阅读 · 0 评论 -
HDU - 3336 (Next数组+dp)
Count the string HDU - 3336 题意:给定字符串s,求s的所有前缀作为子串在s中出现的次数和。 思路:考虑dp dp[i] 表示以第i个字母结尾的所有后缀与s的前缀的匹配次数。 按照最暴力的想法来做的话,肯定我得枚举以第i个字母结尾的每个后缀。 其实也可以这样想:dp[i] 等于s(0,i)最长后缀对结果的贡献加1。然后又kmp里Next数组可以得知,...原创 2018-11-07 21:24:09 · 207 阅读 · 0 评论