
◈DP
aiyouyou_
这个作者很懒,什么都没留下…
展开
-
【HDU 5956】The Elder(树上斜率DP)
思路: 树形DP,dp[i]=min(dp[j]+(sum[i]-sum[j])^2+p) (j是i的祖先即j<i) ,用斜率将复杂度由O(n^2)优化为O(n)。 附上一篇优秀的斜率DP的讲解 此外,在pop的时候可以二分,会更优一些。 但是感觉写起来有点麻烦,这个题不二分的话,时间也稳稳地不会T的。 代码: #include<iostream> #inclu...原创 2018-10-16 21:30:37 · 274 阅读 · 0 评论 -
【ccpc2018吉林D题】THE MOON (概率dp)
题目描述 The Moon card shows alarge, full moon in the night’s sky,positioned between two large towers. The Moon is a symbol of intuition, dreams, and the unconscious. The light of the moon is dim, compa...原创 2019-05-03 16:49:05 · 1319 阅读 · 2 评论