![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
dp
文章平均质量分 83
overload1997
努力 努力 再努力
展开
-
2012杭州赛区(浙江理工大学)C - Substrings
C - SubstringsTime Limit:5000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uSubmit Status Practice HDU 4455DescriptionXXX has an array of length n. XXX wants to kno原创 2016-07-24 15:32:51 · 530 阅读 · 0 评论 -
UVALive 3605 & ZOJ 3135 Roommate(DP)
题目链接:点击打开链接2700+ms过的。。感觉应该还有优化的空间。设dp[i][j][k]为,当前第一个人已经使用了前i个设备,第二个人使用了前j个设备,且第一个人最后一个设备用完的时刻减去第二个人最后一个设备用完的时刻的时间差为k。状态的转移的话,就只有加入第一个人的设备(dp[i+1][j])和加入第二个人的设备(dp[i][j+1])两种选择。首先,从贪心的角度想,原创 2017-03-19 12:23:03 · 353 阅读 · 0 评论 -
UVALive 3608 Period(DP+二分)
题目链接:点击打开链接首先考虑这个问题与一般编辑问题的区别,在这个问题中可以在第二个串的任意地方掐掉重新对第一个串进行dp也就是说,可以将dp[n][j]的状态转移给dp[0][j](n为第一个串的长度)要求的答案是所有段中编辑距离最大的那段的最小值,也就是说需要记录所有从n转移到0的时候的dp[n][j]的值以用来比较取最大。显然这么做十分麻烦,所以可以考虑设一个编辑距离上界原创 2017-03-19 21:06:18 · 245 阅读 · 0 评论 -
UVALive 4613 Mountain Road(DP)
题目链接:点击打开链接车可以减速!车可以减速!车可以减速!重要的事情说三遍!一直在想车可不可以减速想了贼久Orz首先,当某一个方向的车在行驶的时候,除非道路已经空了,否则另一个方向的车是不会走的。于是方案就可以这么设计:A方向连续走过一些车——>B方向连续走过一些车——>A方向连续走过一些车——>B方向连续走过一些车——>。。。。。。确定了分段走的思想之后,就可以确原创 2017-03-10 00:27:23 · 231 阅读 · 0 评论 -
UVALive 4625 Garlands(dp+二分)
题目链接:点击打开链接由于求的是最少的【半段重量最大值】,显然二分重量上界并判断是否可行即可。初步思路是贪心,从左到右将可行的分段尽量拉长。但是这样会遇到一些情况没能够考虑到,例如以下数据:114 5 1018 11 9 96 3 11 96 67 31 12 58 68 98 76这组数据的答案是110,而从左到右的贪心得到的结果是126。于是思路转为求出在当前二分原创 2017-03-07 16:36:55 · 370 阅读 · 0 评论 -
UVALive 3305 Tour(DP)
题目链接:点击打开链接算是被简化了的旅行商问题,其实这道题就是算法导论的第15章的思考题15-3,又称为双调欧几里得旅行商问题。算导里面给出了这个提示:【由左至右扫描,对巡游路线的两个部分分别维护可能的最优解】于是便能够得到这道题的dp状态表示方法了。我们假设其并不是从最左出发至最右再从最右往左走,而是从最左开始同时往右走两条路至最右。于是便可以设dp[i][j]为,从最左原创 2017-03-10 22:05:48 · 249 阅读 · 0 评论 -
UVALive 3637 The Bookcase(DP)
题目链接:点击打开链接用O(n(sum(t)^2))的方法过的心惊胆战。。1800+ms惊险AC。。幸好AC了要是TLE了还得打回去重想。。思路是直接枚举各层宽度,由于书的总宽度固定所有只需要记录下面两层的宽度即可。设dp[k][i][j]为当前书架放了前k本书,第一层宽度为i,第二层宽度为j时的最低高度。为了避免不断去比较高度,先将所有书按从高到低排序,那么只需在空的层中放入原创 2017-03-13 16:18:40 · 235 阅读 · 0 评论 -
UVALive 5717 & HDU 4085 Peach Blossom Spring(DP+斯坦纳树)
题目链接:点击打开链接题目算是比较裸的斯坦纳树,求的是最小的斯坦纳森林,而且其中每颗树都要满足【代表家的点的点数要和代表破屋的点的点数一样多】。首先先求一遍斯坦纳树,这个参考上一篇的斯坦纳树模板。此处设stein[i][bitmask]为以i为根且包含点集中的bitmask状态的点的情况下的最小斯坦纳树。其次,设dp[bitmask]为,在包含点集中的bitmask状态的点原创 2017-03-16 20:51:52 · 554 阅读 · 0 评论 -
Codeforces Round #401 (Div. 2)C. Alyona and Spreadsheet
C. Alyona and Spreadsheettime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputDuring the lesson small girl Alyon原创 2017-04-30 13:57:02 · 184 阅读 · 0 评论 -
Codeforces Round #407 (Div. 2) C. Functions again
C. Functions againtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputSomething happened in Uzhlyandia again...原创 2017-04-06 19:05:55 · 196 阅读 · 0 评论 -
Codeforces Round #422 (Div. 2) C. Hacker, pack your bags!
C. Hacker, pack your bags!time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIt's well known that the best wa原创 2017-07-10 16:03:28 · 341 阅读 · 0 评论 -
Codeforces Round #426 (Div. 2)
D. The Bakerytime limit per test2.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSome time ago Slastyona the Sweetmaid dec原创 2017-08-04 14:42:21 · 210 阅读 · 0 评论 -
hdu 6086 Rikka with String ac自动机+dp
Rikka with StringTime Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 210 Accepted Submission(s): 58Problem DescriptionAs we know,原创 2017-08-09 12:29:15 · 1091 阅读 · 0 评论 -
Codeforces Round #439 (Div. 2) C. The Intriguing Obsession dp
C. The Intriguing Obsessiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output— This is not playing but duty a原创 2017-10-08 14:19:02 · 510 阅读 · 0 评论 -
UVALive 3679 Pitcher Rotation(DP)
题目链接:点击打开链接由于每个打手打完之后需要休息四天,从朴素的dp思路出发,我们只需要记录前四天选哪些打手就行了。设dp[i][s1][s2][s3][s4]为从第1天到第i天,其中第i天选s4号打手,第i-1天选s3号打手,第i-2天选s2号打手,第i-3天选s1号打手的情况下的期望值。状态转移方程为dp[i][s1][s2][s3][s4]=max(dp[i-1][s][s1][原创 2017-03-17 16:36:31 · 266 阅读 · 0 评论 -
Codeforces Round #396 (Div. 2) C.Mahmoud and a Message
C. Mahmoud and a Messagetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMahmoud wrote a message s of lengt原创 2017-02-10 16:41:14 · 161 阅读 · 0 评论 -
Codeforces Round #381 (Div. 2) A. Alyona and copybooks
A. Alyona and copybookstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLittle girl Alyona is in a shop to b原创 2016-11-24 21:54:27 · 311 阅读 · 0 评论 -
2015CCPC南阳场 D - Pick The Sticks
D - Pick The SticksTime Limit:10000MS Memory Limit:65535KB 64bit IO Format:%I64d & %I64uSubmit Status Practice HDU 5543DescriptionThe story happened long long ago. One原创 2016-07-25 21:10:40 · 732 阅读 · 0 评论 -
hdu1950 Bridging signals (nlogn的lis)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1950读完题意你会发现这是一道LIS(最长上升子序列)裸题但n有点大 o(n^2)肯定超时这里我们就要采取nlogn的算法了设dp[i]为长度为i的上升子序列的末元素设len为我们要的答案初始化 len=1,dp[1]=a[i]for(int i=2;i 如果原创 2016-05-26 20:24:49 · 340 阅读 · 0 评论 -
2016多校联赛4D The All-purpose Zero(hdu 5773)
The All-purpose ZeroTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 12 Accepted Submission(s): 4Problem Description?? gets an原创 2016-07-28 17:21:58 · 285 阅读 · 0 评论 -
2016多校联赛4A Another Meaning(hdu 5763)
Another MeaningTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 266 Accepted Submission(s): 114Problem DescriptionAs is known原创 2016-07-28 22:00:05 · 331 阅读 · 0 评论 -
2013长沙现场赛J - Josephina and RPG
题意:给你各个队伍对战的胜率表,然后给你要按顺序挑战的队伍,问全胜的最大胜率是多少。这道题的难点在于,获胜的时候可以选择更换队伍,也可以不更换队伍,一开始你可以选择任意队伍。思路:这道题是一道简单的dp题目,每次只有C(m,3)种状态,每种状态表示当前队伍是哪个,我们用now数组来表示,然后每次有两种选择,更换队伍或不更换队伍。不更换队伍很明显就是now[j] *= t[j][x[i]];更换原创 2016-07-30 17:36:11 · 339 阅读 · 0 评论 -
2016多校联赛6H (hdu5800) To My Girlfriend
To My GirlfriendTime Limit: 2000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 346 Accepted Submission(s): 126Problem DescriptionDear Guo原创 2016-08-05 13:05:18 · 1182 阅读 · 0 评论 -
hdu4433 locker
lockerTime Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1795 Accepted Submission(s): 817Problem DescriptionA password locker wi原创 2016-08-10 18:52:50 · 531 阅读 · 2 评论 -
2015CCPC南阳场 C - The Battle of Chibi
C - The Battle of ChibiTime Limit:4000MS Memory Limit:65535KB 64bit IO Format:%I64d & %I64uSubmit Status Practice HDU 5542DescriptionCao Cao made up a big army and was go原创 2016-07-27 13:43:00 · 843 阅读 · 0 评论 -
hdu 5890 Eighty seven
Eighty sevenTime Limit: 3000/1000 MS (Java/Others) Memory Limit: 102400/102400 K (Java/Others)Total Submission(s): 243 Accepted Submission(s): 74Problem DescriptionMr. Fib is a m原创 2016-09-17 23:19:44 · 562 阅读 · 0 评论 -
hdu 5534 Partial Tree
Partial TreeTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 1045 Accepted Submission(s): 523Problem DescriptionIn mathemati原创 2016-09-20 20:36:52 · 258 阅读 · 0 评论 -
2016ccpc 合肥站hdu 5965 扫雷
扫雷Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 38 Accepted Submission(s): 10Problem Description扫雷游戏是晨晨和小璐特别喜欢的智力游戏,她俩最近沉迷其原创 2016-11-05 18:16:33 · 825 阅读 · 1 评论 -
LightOJ 1422 Halloween Costumes
Halloween CostumesTime Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %lluSubmit Status Practice LightOJ 1422 uDebugDescriptionGappu has a very busy weekend ahead原创 2016-10-16 14:27:49 · 280 阅读 · 0 评论 -
hdu 5900 QSC and Master
QSC and MasterTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 753 Accepted Submission(s): 278Problem DescriptionEvery schoo原创 2016-09-19 22:28:24 · 347 阅读 · 0 评论 -
Codeforces Round #438 by Sberbank and Barcelona Bootcamp (Div. 1 + Div. 2 combined)C - Qualification
C. Qualification Roundstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSnark and Philip are preparing the原创 2017-10-05 21:13:37 · 349 阅读 · 0 评论