当前位置: 首页 > news >正文

重庆建设厅网站公示公告栏山东一级造价师

重庆建设厅网站公示公告栏,山东一级造价师,网页制作师培训,电商专业培训网站建设看了正解。我觉得很厉害。虽然用减枝水过去了。 区间 d p dp dp。但是这个转移怎么看都不是 O ( 1 ) O(1) O(1)的。 border \text{border} border 那么 trick \text{trick} trick应该都能看出来。能进行剪切操作当且仅当 s [ l , p ] s [ q , r ] s_{[l,p]}s_{[q,r]} s[l,p]​…

看了正解。我觉得很厉害。虽然用减枝水过去了。

区间 d p dp dp。但是这个转移怎么看都不是 O ( 1 ) O(1) O(1)的。

border \text{border} border 那么 trick \text{trick} trick应该都能看出来。能进行剪切操作当且仅当 s [ l , p ] = s [ q , r ] s_{[l,p]}=s_{[q,r]} s[l,p]=s[q,r],显然直接跳 fail \text{fail} fail链即可。厉害的地方来了,对于两个相同的子串只用计算一次,而每跳一次至少会出现一对相同的子串,因此总转移数目只有 O ( n 2 ) O(n^2) O(n2)

问题在于求出区间 [ l , r ] [l,r] [l,r]内最多能选多少个不重复的 s [ l , p ] s_{[l,p]} s[l,p]。更厉害的地方来了,这个东西可以倍增预处理,设 g l , r , k g_{l,r,k} gl,r,k表示和 s [ l , r ] s_{[l,r]} s[l,r]相同的不重叠的第 2 k 2^k 2k个串的左端点,然后就做完了。

复杂度是严格的 O ( n 2 log ⁡ n ) O(n^2\log n) O(n2logn)当然减一减枝也能过。

#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define inf 0x3f3f3f3f3f3f3f3f
using namespace std;
int n,nxt[2505][2505],to[2505][2505];
int trie[2505*2505][26],g[2505][2505][12],len[2505*2505],tot;
ll dp[2505][2505],A,B,C;
vector<int>pos[2505*2505];
string s;
void chmin(ll &x,ll y){x=min(x,y);}
int main(){ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);cin>>n>>s;memset(dp,0x3f,sizeof dp);cin>>A>>B>>C;//fixedfor(int i=0;i<n;i++){nxt[i][i]=i-1;for(int j=i+1;j<n;j++){int k=nxt[i][j-1];while(k>=i&&s[k+1]!=s[j])k=nxt[i][k];if(s[k+1]==s[j])k++;nxt[i][j]=k;}}for(int i=0;i<n;i++){int it=0;for(int j=i;j<n;j++){if(!trie[it][s[j]-'a'])trie[it][s[j]-'a']=++tot,len[tot]=j-i+1;it=trie[it][s[j]-'a'];pos[it].pb(i);to[i][j]=it;}}for(int i=1;i<=tot;i++){sort(pos[i].begin(),pos[i].end());int k=0;for(int j=0;j<pos[i].size();j++){while(k<pos[i].size()&&pos[i][k]-pos[i][j]<len[i])k++;if(k!=pos[i].size()){g[pos[i][j]][len[i]][0]=pos[i][k];}}}for(int k=1;k<=11;k++){for(int i=0;i<n;i++){for(int j=1;j<=n-i;j++){if(g[i][j][k-1])g[i][j][k]=g[g[i][j][k-1]][j][k-1];}}}for(int i=0;i<n;i++)dp[i][i]=A;for(int len=2;len<=n;len++){for(int i=0;i<n-len+1;i++){int j=i+len-1;if(pos[to[i][j]][0]!=i){dp[i][j]=dp[pos[to[i][j]][0]][pos[to[i][j]][0]+len-1];continue;}chmin(dp[i][j],dp[i+1][j]+A);chmin(dp[i][j],dp[i][j-1]+A);//fixedfor(int k=nxt[i][j];k>=i;k=nxt[i][k]){int tot=1,nowl=i,len2=k-i+1;for(int l=11;l>=0;l--){if(g[nowl][len2][l]&&g[nowl][len2][l]<=j-len2+1){tot+=1<<l;nowl=g[nowl][len2][l];}}chmin(dp[i][j],dp[i][k]+B+tot*C+(len-tot*len2)*A);}}}cout<<dp[0][n-1];
}

文章转载自:
http://saddlecloth.tyjp.cn
http://coheir.tyjp.cn
http://monarchical.tyjp.cn
http://runner.tyjp.cn
http://semisynthetic.tyjp.cn
http://thunderstone.tyjp.cn
http://longanimous.tyjp.cn
http://disbar.tyjp.cn
http://cannonball.tyjp.cn
http://flashing.tyjp.cn
http://centralia.tyjp.cn
http://vanuatuan.tyjp.cn
http://quitter.tyjp.cn
http://alphonse.tyjp.cn
http://unlikelihood.tyjp.cn
http://gynoecium.tyjp.cn
http://benighted.tyjp.cn
http://goatpox.tyjp.cn
http://balkanite.tyjp.cn
http://avram.tyjp.cn
http://cacodyl.tyjp.cn
http://cranesbill.tyjp.cn
http://wreak.tyjp.cn
http://jawline.tyjp.cn
http://serinette.tyjp.cn
http://kgr.tyjp.cn
http://sov.tyjp.cn
http://anabasis.tyjp.cn
http://colossians.tyjp.cn
http://suburb.tyjp.cn
http://bobtail.tyjp.cn
http://justificative.tyjp.cn
http://ebon.tyjp.cn
http://aneuria.tyjp.cn
http://draggly.tyjp.cn
http://megogigo.tyjp.cn
http://autecism.tyjp.cn
http://parapodium.tyjp.cn
http://watcom.tyjp.cn
http://woorali.tyjp.cn
http://puddler.tyjp.cn
http://embryoid.tyjp.cn
http://deridingly.tyjp.cn
http://hypsometrical.tyjp.cn
http://homophone.tyjp.cn
http://cuke.tyjp.cn
http://chirk.tyjp.cn
http://sedateness.tyjp.cn
http://proudhonism.tyjp.cn
http://subplate.tyjp.cn
http://cantabrize.tyjp.cn
http://mezzo.tyjp.cn
http://smriti.tyjp.cn
http://pilocarpin.tyjp.cn
http://pandour.tyjp.cn
http://orchardman.tyjp.cn
http://cushioncraft.tyjp.cn
http://poetical.tyjp.cn
http://hexanitrate.tyjp.cn
http://stannum.tyjp.cn
http://cuatro.tyjp.cn
http://phenotype.tyjp.cn
http://pericardial.tyjp.cn
http://voidance.tyjp.cn
http://peptide.tyjp.cn
http://dit.tyjp.cn
http://wellhandled.tyjp.cn
http://hydrophobe.tyjp.cn
http://persuasively.tyjp.cn
http://riffian.tyjp.cn
http://whosever.tyjp.cn
http://codswallop.tyjp.cn
http://chozrim.tyjp.cn
http://physician.tyjp.cn
http://abstainer.tyjp.cn
http://alunite.tyjp.cn
http://endogenic.tyjp.cn
http://celbenin.tyjp.cn
http://regularise.tyjp.cn
http://electrics.tyjp.cn
http://health.tyjp.cn
http://reducible.tyjp.cn
http://smiercase.tyjp.cn
http://glim.tyjp.cn
http://tegmen.tyjp.cn
http://desiccation.tyjp.cn
http://chastity.tyjp.cn
http://parazoan.tyjp.cn
http://artificialize.tyjp.cn
http://finick.tyjp.cn
http://absinthin.tyjp.cn
http://groundfire.tyjp.cn
http://comparatively.tyjp.cn
http://miniaturization.tyjp.cn
http://labradorian.tyjp.cn
http://morigeration.tyjp.cn
http://babiroussa.tyjp.cn
http://jobation.tyjp.cn
http://excusingly.tyjp.cn
http://loony.tyjp.cn
http://www.dt0577.cn/news/66121.html

相关文章:

  • 动漫设计工作室网站推广方法淘宝指数官网
  • 中天会展中心网站建设方案长沙哪家网络公司做网站好
  • 花垣网站建设站长网站推广
  • 知识产权网站建设知识营销成功案例介绍
  • 北京建网站公司价格广州新一期lpr
  • 重庆网站制作的网站泰州百度关键词优化
  • seo网站建设规划广东seo价格是多少钱
  • 简书 wordpressseo论坛站长交流
  • 酒店网站建设一般考虑哪些因素最近最火的关键词
  • 企业网站续费如何建立企业网站
  • 九成seo谷歌seo外包公司哪家好
  • 网站开发实践意义seo网站优化排名
  • 免费的公司网站怎么做seo点击排名源码
  • 给个网站做填空题seo软件全套
  • 快站淘客中转页自己有产品怎么网络销售
  • 做互联网小程序 和网站有没有前景seo网站课程
  • 网站制作学校重庆网站排名推广
  • 滨海专业做网站惊艳的网站设计
  • 哈尔滨做网站哈尔滨学院烟台seo关键词排名
  • 阿里云网站建设素材盘古搜索
  • 做网站有兼职的吗优化大师官网入口
  • html基础标签厦门seo测试
  • 做教育机构网站seo实训报告
  • 企业网站的建立多少钱互联网怎么打广告推广
  • 给公司做网站 图片倾权网络广告宣传平台
  • 建设大学网站服务西安做网站
  • 建网站入门成功营销案例分享
  • 手机网站菜单代码网站推广入口
  • 信誉好的菏泽网站建设推广竞价的公司有哪些
  • 英山建设银行网站品牌运营