BZOJ 1264: [AHOI2006]基因匹配Match|动态规划
来源:互联网 发布:umeng移动端数据统计 编辑:程序博客网 时间:2024/05/23 01:14
朴素的动规是n方的
数据范围有点大
考虑一下转移的时候 a[i]==b[j]
开个数组把这与相等的5个数的位置存下来
然后用树状数组维护各max{前缀}就ok了
话说为什么最近总是犯一些傻逼的错误………………
#include<cstdio>#include<cstdlib>#include<cstring>#include<cmath>#include<queue>#include<vector>#include<set>#include<map>#include<algorithm>#include<iostream>#define T 200020#define lowbit(x) (x&(-x))using namespace std;int sc(){int i=0;char c=getchar();while(c>'9'||c<'0')c=getchar();while(c>='0'&&c<='9')i=i*10+c-'0',c=getchar();return i;}int pos[T][5],tr[T];int n,ans=0;void change(int x,int y){for(;x<=n;x+=lowbit(x))tr[x]=max(tr[x],y);}int ask(int x){int ans=0;for(;x;x-=lowbit(x))ans=max(ans,tr[x]);return ans;}int main(){n=sc();n*=5;for(int i=1;i<=n;i++){int x=sc(),j=0;while(pos[x][j])j++;pos[x][j]=i;}for(int i=1;i<=n;i++){int x=sc();for(int j=4;~j;j--){int y=ask(pos[x][j]-1)+1;ans=max(ans,y);change(pos[x][j],y);}}cout<<ans;return 0;}
0 0
- BZOJ 1264 AHOI2006 基因匹配Match 动态规划+树状数组
- BZOJ 1264: [AHOI2006]基因匹配Match|动态规划
- bzoj 1264: [AHOI2006]基因匹配Match
- bzoj 1264: [AHOI2006]基因匹配Match
- 1264: [AHOI2006]基因匹配Match
- bzoj 1264 [AHOI2006]基因匹配Match(DP+树状数组)
- BZOJ 1264: [AHOI2006]基因匹配Match 树状数组,DP
- bzoj 1264: [AHOI2006]基因匹配Match (DP+树状数组)
- BZOJ 1264 [AHOI2006]基因匹配Match DP+BIT
- bzoj 1264: [AHOI2006]基因匹配Match 树状数组
- bzoj 1264: [AHOI2006]基因匹配Match(树状数组)
- bzoj1264: [AHOI2006]基因匹配Match
- BZOJ1264: [AHOI2006]基因匹配Match
- bzoj1264: [AHOI2006]基因匹配Match
- 1264: [AHOI2006]基因匹配Match DP+树状数组
- BZOJ1264——[AHOI2006]基因匹配Match
- 【BZOJ1264】[AHOI2006]基因匹配Match【DP】【LCS】【树状数组】
- bzoj1264 [AHOI2006]基因匹配Match (树状数组优化DP)
- 仿Ios弹窗效果一
- C#源代码—在windows窗体中添加一个名为lblShow的Lable控件4,创建可变字符串,字符串转换为字符型
- List集合去掉重复代码
- 2016【太原UI设计师】郭文军讲解Windowsphone界面设计的规范
- poi 导出excel(传入map类型)
- BZOJ 1264: [AHOI2006]基因匹配Match|动态规划
- java 多线程(3) 线程的基本概念 / 创建和启动 / run() / start()
- 关闭横屏 只允许竖屏
- CodeForces 413B Spyke Chatting
- myeclipse8.5破解
- 微信XML解析
- KVO Considered Harmful
- shell脚本中单引号和双引号的区别
- apache下配置多域名。