
DP优化
文章平均质量分 57
wwt9b15bs
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
【题解】poj1738石子合并 区间DP 加西亚瓦克斯算法
题目链接 乍一看很激动(诶辣鸡题才做过)然后n=4e4+o(n^3)=GG GarsiaWachs算法 或者四边形优化(还是GG不用搞了)(以后自己写一遍) 还可以加上个平衡树(憋说了……) step 0:初始数组为num[1..n],num[0] = num[n+1] = INF step 1:每次找到一个最小的i使得num[i-1]<=num[i+1],将num[i-1]和n...原创 2018-08-15 07:10:47 · 547 阅读 · 0 评论 -
【题解】[牛客网NOIP赛前集训营-提高组(第七场)]C.洞穴 倍增优化DP+bitset
题目链接#include<cstdio>#include<bitset>using namespace std;const int N=110;int n,m,q;bitset<N>f[N][31];int main(){ //freopen("in.txt","r",stdin); scanf("%d%d",&n,&原创 2018-11-01 10:15:05 · 248 阅读 · 0 评论 -
【题解】poj3171 Cleaning Shifts 线段树优化DP
题目链接DescriptionFarmer John’s cows, pampered since birth, have reached new heights of fastidiousness. They now require their barn to be immaculate. Farmer John, the most obliging of farmers, has no c...原创 2018-09-29 18:10:41 · 595 阅读 · 0 评论 -
【题解】CH5702 Count The Repetitions 倍增优化DP
题目链接描述定义 conn(s,n)conn(s,n)conn(s,n) 为 nnn 个字符串 sss 首尾相接形成的字符串,例如:conn(“abc”,2)="abcabc称字符串 aaa 能由字符串 bbb 生成,当且仅当从字符串 bbb 中删除某些字符后可以得到字符串 aaa。例如“abdbec”可以生成“abc”,但是“acbbe”不能生成“abc”。给定两个字符串 s1s_1s...原创 2018-09-28 23:00:28 · 462 阅读 · 0 评论 -
【题解】hdu3507 斜率优化
题目链接/*假设sum[i]表示前i项和dp[i]表示前i项需要花费的最少值则dp[i]=min((sum[i]-sum[j])^2+m+dp[j]);//j=0~i-1=&amp;gt;dp[i]=min(sum[i]*sum[i]+2*sum[i]*sum[j]+sum[j]*sum[j]+m+dp[j]);由于存在sum[i]*sum[j]和i有关的这一项,所以不可能用单调队列来维护...原创 2018-08-14 06:58:47 · 183 阅读 · 0 评论 -
【题解】洛谷P3628[APIO2010]特别行动队 斜率优化
第一道AC的紫题,纪念一下#include&amp;lt;cstdio&amp;gt;typedef long long ll;const int N=1e6+10;ll sum[N],dp[N],q[N];int a,b,c,n;ll gety(int j,int k){ return (dp[j]+a*sum[j]*sum[j]-dp[k]-a*sum[k]*sum[k]);}l...原创 2018-08-14 06:58:36 · 335 阅读 · 0 评论 -
【题解】洛谷P1081(同CH5701)开车旅行[NOIP2012] 倍增优化DP+离散+链表
题目链接 学习了大佬博客,讲的很好#include&amp;lt;cstdio&amp;gt;#include&amp;lt;algorithm&amp;gt;#include&amp;lt;cmath&amp;gt;#include&amp;lt;climits&amp;gt;using namespace std;#define _rep(i,a,b) fo原创 2018-09-05 07:18:36 · 326 阅读 · 0 评论 -
【题解】洛谷P4852[非酋yyf的sif之旅]B.yyf hates choukapai 单调队列优化DP
题目链接赛后题解#include&lt;cstdio&gt;const int M=8e4+5,C=3e3+5,N=45,S=N*C+M;int a[S],b[S],n,m,c,d,sum,hd[N],tl[N],s,q[N][S][2],f[S][N],p[S][N],pos[N],ans,Pos;//f[i][j]前i张牌连抽j次 p[i][j]记录f[i][j]由哪个i转移过...转载 2018-10-03 17:21:41 · 270 阅读 · 0 评论 -
【题解】牛客OI周赛1-提高组 C.序列 计数类DP+前缀和优化
链接:https://www.nowcoder.com/acm/contest/199/C来源:牛客网我们枚举不同数字的个数 xxx 。此时等价于这个问题,有 x 个箱子排成一排,任意两个箱子之间距离不超过 k(超过 k 意味着可以把这个间距减小到 k,且是一个等价的序列),第一个箱子和最后一个箱子的距离不超过 m 的方案数。设 F[i,j]F[i,j]F[i,j] 表示放置了 ii...原创 2018-10-02 18:55:59 · 433 阅读 · 1 评论 -
【题解】洛谷P2569[SCOI2010]股票交易 背包问题+单调队列优化
题目链接 学习了大佬题解,这波方程变形后单调队列维护天秀。#include&lt;cstdio&gt;#include&lt;algorithm&gt;using namespace std;#define _rep(i,a,b) for(int i=(a);i&lt;=(b);i++)#define rep_(i,a,b) for(int i=(a);i&gt;=(b);i--...原创 2018-09-05 07:19:38 · 337 阅读 · 0 评论 -
【题解】[牛客网NOIP赛前集训营-提高组(第四场)]C.灭虫 线性DP+堆优化
题目链接#include<cstdio>#include<algorithm>#include<queue>using namespace std;const int N=3e3+10;struct node{ int p,l,r; bool operator <(const node&rhs)const{ retur...原创 2018-10-30 22:50:58 · 256 阅读 · 0 评论