HDU 1423 子序列
来源:互联网 发布:艾媒数据统计 编辑:程序博客网 时间:2024/05/29 04:41
Greatest Common Increasing Subsequence
Problem Description
This is a problem from ZOJ 2432.To make it easyer,you just need output the length of the subsequence.
Input
Each sequence is described with M - its length (1 <= M <= 500) and M integer numbers Ai (-2^31 <= Ai < 2^31) - the sequence itself.
Output
output print L - the length of the greatest common increasing subsequence of both sequences.
Sample Input
151 4 2 5 -124-12 1 2 4
Sample Output
2
求两个序列的最长公共递增子序列
#include<iostream>#include<cstdio>#include<cstring>using namespace std;const int maxn=555;int a[maxn],b[maxn],len[maxn];int n,m;//a,b数组的长度int LCIS(){int locate;memset(len,0,sizeof(len));for(int i=1;i<=n;++i){locate=1;for(int j=1;j<=m;++j){if(b[j]<a[i]&&len[j]>len[locate])locate=j;if(a[i]==b[j])len[j]=len[locate]+1;}}int max=-1;for(int i=1;i<=m;i++)max=max>len[i]?max:len[i];return max;}int main(){int t;scanf("%d",&t);int i,j;while(t--){scanf("%d",&n);for(i=1;i<=n;++i)scanf("%d",&a[i]);scanf("%d",&m);for(i=1;i<=m;++i)scanf("%d",&b[i]);int ans=LCIS();printf("%d\n",ans);if(t)printf("\n");}return 0;}
- HDU 1423 子序列
- HDU 1423 最长上升公共子序列
- hdu 1423 最长公共递增子序列
- hdu 1423 最长公共上升子序列
- hdu 1423最长公共递增子序列
- hdu 1423 最长递增公共子序列
- hdu 1423(最长公共上升子序列)
- HDU 1257 子序列
- HDU 1159 子序列
- HDU 1711 子序列
- HDU 2087 子序列
- HDU 1686 子序列
- HDU 2594 子序列
- HDU 1025 子序列
- hdu 1423+hdu 4512 最长公共递增子序列
- 最长递增公共子序列dp(hdu 1423 hdu 4512)
- hdu 1087 最长子序列
- hdu 1159 公共子序列
- oracle中常用函数
- Problems when installing rt-xen 1.0 on fedora18(64bit)
- GoFundMe上为其筹得资金11000美元
- 最近做的RTSP流媒体实时直播项目
- 如何查找Linux系统网卡流量的SNMP OID 这个基本靠推理
- HDU 1423 子序列
- 自适应大小
- asp.net ListView控件用法简介
- 谷歌获取地址经纬度
- ueditor1_2_6_1-utf8-net传解决本地图片上传失败问题
- Windows 核心编程之14 探索虚拟内存
- SqlDataReader
- Java构造函数
- Blender学习笔记三