![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
ACM__动态规划
DP
P1n9
这个作者很懒,什么都没留下…
展开
-
DP第一题:poj1018---Communication System
Communication System Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 31193 Accepted: 11040 DescriptionWe have received an order from Pizoor Communications Inc. for a specia...原创 2018-07-29 16:03:52 · 170 阅读 · 0 评论 -
练习赛补题-------K - Watermelon Full of Water DP
Watermelon is very popular in the hot summer. Students in ZJU-ICPC Team also love watermelon very much and they hope that they can have watermelon to eat every day during the summer vacation. Suppose ...原创 2019-03-28 11:49:56 · 212 阅读 · 0 评论 -
练习赛补题--------E - Treasure Hunt I DP
Akiba is a dangerous country since a bloodsucker living there. Sometimes the bloodsucker will appear and kill everyone who isn’t at his hometown. One day, a brave person named CC finds a treasure map,...原创 2019-03-28 10:47:29 · 139 阅读 · 0 评论 -
练习赛补题-------B - Battle Ships
Battle Ships is a new game which is similar to Star Craft. In this game, the enemy builds a defense tower, which has L longevity. The player has a military factory, which can produce N kinds of battle...原创 2019-03-28 10:22:13 · 138 阅读 · 0 评论 -
DP专题-----D - Doing Homework (状压DP)
Ignatius has just come back school from the 30th ACM/ICPC. Now he has a lot of homework to do. Every teacher gives him a deadline of handing in the homework. If Ignatius hands in the homework after th...原创 2019-04-01 15:44:45 · 197 阅读 · 0 评论 -
DP专题-------P - FatMouse and Cheese 记忆化搜索
FatMouse has stored some cheese in a city. The city can be considered as a square grid of dimension n: each grid location is labelled (p,q) where 0 <= p < n and 0 <= q < n. At each grid lo...原创 2019-04-10 17:13:49 · 140 阅读 · 0 评论 -
DP专题--------O - Treats for the Cows 区间DP
FJ has purchased N (1 <= N <= 2000) yummy treats for the cows who get money for giving vast amounts of milk. FJ sells one treat per day and wants to maximize the money he receives over a given p...原创 2019-04-10 16:25:59 · 143 阅读 · 0 评论 -
DP专题----C - Monkey and Banana (最长递增子序列)
A group of researchers are designing an experiment to test the IQ of a monkey. They will hang a banana at the roof of a building, and at the mean time, provide the monkey with some blocks. If the monk...原创 2019-03-31 23:39:08 · 176 阅读 · 0 评论 -
练习赛补题-----C - Game Map dp
题意:给定一个图,在图上要求找一个最长链,使得后面一个点的度数比前一个点的度数大,问最长的长度是多少?可以利用拓扑排序的方式进行dp,首先更新dp值全为1,然后遍历度数,每次找出最小的度数,更新完dp之后,删去这些点,再找最小的度数。。。。,最后的最大的dp值就是答案。dp[i]代表到i点的最长的链的长度#include<bits/stdc++.h>using namespac...原创 2019-04-05 11:42:37 · 155 阅读 · 0 评论 -
DP专题-------K - Jury Compromise DP
In Frobnia, a far-away country, the verdicts in court trials are determined by a jury consisting of members of the general public. Every time a trial is set to begin, a jury has to be selected, which ...原创 2019-04-07 10:33:44 · 112 阅读 · 0 评论 -
DP专题------M - Help Jimmy
“Help Jimmy” 是在下图所示的场景上完成的游戏。场景中包括多个长度和高度各不相同的平台。地面是最低的平台,高度为零,长度无限。Jimmy老鼠在时刻0从高于所有平台的某处开始下落,它的下落速度始终为1米/秒。当Jimmy落到某个平台上时,游戏者选择让它向左还是向右跑,它跑动的速度也是1米/秒。当Jimmy跑到平台的边缘时,开始继续下落。Jimmy每次下落的高度不能超过MAX米,不然就会...原创 2019-04-07 20:04:31 · 174 阅读 · 0 评论 -
最长公共子串
暴力和动态规划均可做主要是了解动态规划怎么做;我们发现,在相同开端的子串的比较中,有很多事重复动作。比如在比较以i,j分别为起点的子串时,有可能会进行i+1和j+1以及i+2和j+2位置的字符的比较。而以i+1,j+1分别为起点的子串时,这些字符又被比较了一次。也就说该问题有非常相似的子问题,而子问题之间又有重叠,这就给动态规划法创造了契机。暴力解法是以子串开端开始寻找,现在换个思路,以相...原创 2019-09-07 10:08:52 · 162 阅读 · 0 评论 -
华为机试---动态规划---优化编辑器问题
版权声明:本文为CSDN博主「wskyp」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。原文链接:https://blog.csdn.net/u014226012/article/details/65937179问题描述Levenshtein 距离,又称编辑距离,指的是两个字符串之间,由一个转换成另一个所需的最少编辑操作次数。许可的编辑操作包括将一个字...转载 2019-09-06 10:01:18 · 454 阅读 · 0 评论 -
金明的预算方案(01背包的变式)
带有附件的背包问题,它属于01背包的变式每一个物品最多只有两个附件,那么我们在对主件进行背包的时候,决策就不再是两个了,而是五个。01背包的决策是:1.不选,然后去考虑下一个2.选,背包容量减掉那个重量,总值加上那个价值。这个题的决策是五个,分别是:1.不选,然后去考虑下一个2.选且只选这个主件3.选这个主件,并且选附件14.选这个主件,并且选附件25.选这个主件,并且选附件...原创 2019-07-23 10:02:17 · 131 阅读 · 0 评论 -
DP专题--------Q - Phalanx最大对称子矩阵
Today is army day, but the servicemen are busy with the phalanx for the celebration of the 60th anniversary of the PRC.A phalanx is a matrix of size nn, each element is a character (a~z or A~Z), stan...原创 2019-04-12 17:43:18 · 180 阅读 · 0 评论 -
DP专题------G - 免费馅饼
都说天上不会掉馅饼,但有一天gameboy正走在回家的小径上,忽然天上掉下大把大把的馅饼。说来gameboy的人品实在是太好了,这馅饼别处都不掉,就掉落在他身旁的10米范围内。馅饼如果掉在了地上当然就不能吃了,所以gameboy马上卸下身上的背包去接。但由于小径两侧都不能站人,所以他只能在小径上接。由于gameboy平时老呆在房间里玩游戏,虽然在游戏中是个身手敏捷的高手,但在现实中运动神经特别迟钝...原创 2019-04-03 15:39:35 · 116 阅读 · 0 评论 -
pat1068 1068 Find More Coins (30 分)
地址:https://pintia.cn/problem-sets/994805342720868352/problems/994805402305150976利用01背包求解,体积与价值都设为对应的钱币值,因为同时存在多个时,需要输出最小的,所以将钱币数按从大到小的顺序进行排序,用flag[i][j]代表第i个钱币对于加和为j是否被选,如果被选,那么是true,没有被选,就是false;如果求...原创 2019-02-28 20:16:03 · 188 阅读 · 0 评论 -
pat1049 Counting Ones 数位dp+记忆化搜索
地址:https://pintia.cn/problem-sets/994805342720868352/problems/994805430595731456数位dp详解见:https://blog.csdn.net/qq_36386435/article/details/81319116https://blog.csdn.net/qq_36386435/article/details/8...原创 2019-02-21 16:23:15 · 162 阅读 · 0 评论 -
DP第四题hdu1069 Monkey and Banana
Monkey and Banana Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 19770 Accepted Submission(s): 10522Problem Description A group of res...原创 2018-08-07 19:03:22 · 96 阅读 · 0 评论 -
DP第三题 hdu 1024 Max Sum Plus Plus
Max Sum Plus Plus Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 36771 Accepted Submission(s): 13114Problem Description Now I think yo...转载 2018-08-06 21:24:42 · 121 阅读 · 0 评论 -
牛客网多校第四场-----C Chiaki Sequence Reloaded
转载:https://blog.csdn.net/xianpingping/article/details/81292942 链接:https://www.nowcoder.com/acm/contest/142/C 来源:牛客网Chiaki Sequence Reloaded 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 131072K,其他语言262144K 6...转载 2018-08-01 10:09:20 · 256 阅读 · 0 评论 -
数位DP应用三题
转载:https://blog.csdn.net/brazy/article/details/77427699 https://www.cnblogs.com/zbtrs/p/6106783.html例一、Valley Numer Time Limit: 2000/1000 MS (Java/O...转载 2018-07-31 21:38:27 · 211 阅读 · 0 评论 -
数位DP入门
转载:https://blog.csdn.net/brazy/article/details/77427699 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;https://www.cnblogs.com/zbtrs/p/6106783.html转载 2018-07-31 19:29:18 · 156 阅读 · 0 评论 -
动态规划的背包问题
转载:https://blog.csdn.net/stack_queue/article/details/53544109目录 一、 01背包问题 二、完全背包问题 三、多重背包问题 四、 混合三种背包问题 五、二维费用的背包问题 六、 分组的背包问题 简单介绍 1、01背包:每个物品只能放一次 2、完全背包:每种物品可以放无限多次 3、多重背包:每种物品有一个...转载 2018-07-27 18:45:49 · 152 阅读 · 0 评论 -
牛客多校3--第一题PACMteam
链接:https://www.nowcoder.com/acm/contest/141/A 来源:牛客网PACM Team 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 262144K,其他语言524288K Special Judge, 64bit IO Format: %lld 题目描述 Eddy was a contestant participating...原创 2018-07-27 16:22:59 · 215 阅读 · 0 评论 -
DP第二题:poj1050------To the Max
To the Max Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 52190 Accepted: 27587 DescriptionGiven a two-dimensional array of positive and negative integers, a sub-rectangle...原创 2018-07-29 20:40:15 · 104 阅读 · 0 评论 -
DP第五题hdu1074 Doing Homework(状压)
Doing Homework Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 12028 Accepted Submission(s): 5773Problem Description Ignatius has just ...转载 2018-08-07 21:08:47 · 140 阅读 · 0 评论 -
树形dp初次学习
1、什么是树型动态规划 顾名思义,树型动态规划就是在“树”的数据结构上的动态规划,平时作的动态规划都是线性的或者是建立在图上的,线性的动态规划有二种方向既向前和向后,相应的线性的动态规划有二种方法既顺推与逆推,而树型动态规划是建立在树上的,所以也相应的有二个方向: 1、叶->根:在回溯的时候从叶子节点往上更新信息2、根 - >叶:往往是在从叶往根dfs一遍之后(相当于预处理...转载 2018-08-28 22:19:30 · 201 阅读 · 0 评论 -
HDU-6249 Alice’s Stamps(DP)
Alice’s StampsTime Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1430 Accepted Submission(s): 494Problem DescriptionAlice likes to collect s...原创 2019-01-13 20:39:02 · 129 阅读 · 0 评论 -
HDU-5119 Happy Matt Friends(dp)
Matt has N friends. They are playing a game together.Each of Matt’s friends has a magic number. In the game, Matt selects some (could be zero) of his friends. If the xor (exclusive-or) sum of the sel...原创 2018-11-18 10:16:06 · 141 阅读 · 0 评论 -
Codeforces Round #510 (Div. 2) B. Vitamins(暴力状压DP)
地址:http://codeforces.com/contest/1042/problem/B他的情况只有A,B,C,AB,BC,AC,ABC七种,可以先将n个果汁进行两两组合更新七种情况的值,然后在七种两辆组合更新,这是比较暴力的解法#include<bits/stdc++.h>using namespace std;typedef long long LL;const i...原创 2018-09-18 20:26:04 · 219 阅读 · 0 评论 -
ccf 201612-4 压缩编码
201612-4 试题名称: 压缩编码 时间限制: 3.0s 内存限制: 256.0MB 问题描述: 问题描述 给定一段文字,已知单词a1, a2, …, an出现的频率分别t1, t2, …, tn。可以用01串给这些单词编码,即将每个单词与一个01串对应,使得任何一个单词的编码(对应的01串)不是另一个单词编码的前缀,这种编码称为前缀码。 使用前缀码编码一段文...原创 2018-09-12 17:56:47 · 671 阅读 · 0 评论 -
无法拯救我的菜-----焦作网络赛 K. Transport Ship
地址:https://nanti.jisuanke.com/t/31720多重背包 + 二进制优化 将多重背包转化为01背包求解,dp[j]代表运送物资的重量为j所有的方案数 动态规划方程:dp[j] = dp[j] + dp[j - w[i]] w[i]代表船可运输重量#include<bits/stdc++.h>using namespace std;typed...原创 2018-09-16 10:08:53 · 253 阅读 · 0 评论 -
无法拯救我的菜-----焦作网络赛 B. Mathematical Curse
地址:https://nanti.jisuanke.com/t/31711这个dp是个简单dp,赛场上思路是对的,负负得正,说明当前最大值可以来自前面的最大值或者最小值。。。。这个没想到,还是菜。。。。。。 dp[i][j]表示选到了第i个数时用了j个运算符,观察发现,一个数只能由他前一个状态的最大值或最小值转移过来(因为乘上一个负数会使最小的数变最大),所以我们同时维护最大最小。 然后转...原创 2018-09-15 20:46:52 · 203 阅读 · 0 评论 -
Codeforces Round #506 (Div. 3) B. Creating the Contest
地址:http://codeforces.com/contest/1029/problem/Bdp思想,这种做法真是麻烦,dp[i] = max(dp[j]) (j是满足a[j] &lt; a[i] &lt;=2 * a[j] )+ 1; 因为n是1e5,所以会超时,j是连续的一段区间,用二分找到区间的左边界,然后用线段树求区间最大值#include&lt;bits/stdc++.h&g...原创 2018-09-02 10:17:52 · 110 阅读 · 0 评论 -
无法拯救我的菜系列------hdu6447 YJJ's Salesman
YJJ’s Salesman Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 1716 Accepted Submission(s): 635Problem Description YJJ is a salesman wh...转载 2018-08-28 23:21:20 · 251 阅读 · 0 评论 -
计算字符串的相似度
地址:https://www.nowcoder.com/practice/f549ee08ddd84b8485a4fa9aefaf4a38?tpId=37&tqId=21302&rp=0&ru=%2Fta%2Fhuawei&qru=%2Fta%2Fhuawei%2Fquestion-ranking是一个经典dp,最小编辑距离算法 Edit Distance(经典D...原创 2019-09-09 20:57:22 · 150 阅读 · 0 评论