HDU-1423-Greatest Common Increasing Subsequence-最长公共上升子序列【模版】
InputEach sequence is described with M - its length (1 <= M <= 500) and M integer numbers Ai (-2^31 <= Ai < 2^31) - the sequence itself.Outputoutput print L - the length of the greatest common increasing subsequence of both sequences.Sample Input
1 5
1 4 2 5 -12
4
-12 1 2 4
Sample Output
2 注意一下控制格式
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<string.h>
using namespace std; int a[];
int b[];
int dp[]; int main()
{
std::ios::sync_with_stdio(false);
cin.tie();
cout.tie();
int tt;
cin>>tt;
while(tt--)
{
memset(a,,sizeof(a));
memset(b,,sizeof(b));
memset(dp,,sizeof(dp));
int p,q;
cin>>p;
for(int i=;i<p;i++)
cin>>a[i];
cin>>q;
for(int i=;i<q;i++)
cin>>b[i];
int maxx;
for(int i=;i<p;i++)
{
maxx=;//每次都要恢复
for(int j=;j<q;j++)
{
if(a[i]>b[j])
maxx=max(dp[j],maxx);
else if(a[i]==b[j])
dp[j]=maxx+;
}
}
int ans=;
for(int i=;i<q;i++)
ans=max(ans,dp[i]);
if(tt)
cout<<ans<<endl<<endl;
else
cout<<ans<<endl;
}
return ;
}
HDU-1423-Greatest Common Increasing Subsequence-最长公共上升子序列【模版】的更多相关文章
- HDU 1423 Greatest Common Increasing Subsequence(最长公共上升LCIS)
HDU 1423 Greatest Common Increasing Subsequence(最长公共上升LCIS) http://acm.hdu.edu.cn/showproblem.php?pi ...
- HDU 1423 Greatest Common Increasing Subsequence(LICS入门,只要求出最长数)
Greatest Common Increasing Subsequence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536 ...
- HDU 1423 Greatest Common Increasing Subsequence LCIS
题目链接: 题目 Greatest Common Increasing Subsequence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: ...
- HDU 1423 Greatest Common Increasing Subsequence(LCIS)
Greatest Common Increasing Subsequenc Problem Description This is a problem from ZOJ 2432.To make it ...
- HDU 1423 Greatest Common Increasing Subsequence
最长公共上升子序列 LCIS 看这个博客 http://www.cnblogs.com/nuoyan2010/archive/2012/10/17/2728289.html #include&l ...
- HDU 1423 Greatest Common Increasing Subsequence ——动态规划
好久以前的坑了. 最长公共上升子序列. 没什么好说的,自己太菜了 #include <map> #include <cmath> #include <queue> ...
- HDOJ 1423 Greatest Common Increasing Subsequence 【DP】【最长公共上升子序列】
HDOJ 1423 Greatest Common Increasing Subsequence [DP][最长公共上升子序列] Time Limit: 2000/1000 MS (Java/Othe ...
- HDOJ 1423 Greatest Common Increasing Subsequence -- 动态规划
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1423 Problem Description This is a problem from ZOJ 2 ...
- POJ 1423 Greatest Common Increasing Subsequence【裸LCIS】
链接: http://acm.hdu.edu.cn/showproblem.php?pid=1423 http://acm.hust.edu.cn/vjudge/contest/view.action ...
- HDUOJ ---1423 Greatest Common Increasing Subsequence(LCS)
Greatest Common Increasing Subsequence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536 ...
随机推荐
- 在当前对象中可以使用this关键字指代当前对象
在当前对象中可以使用this关键字指代当前对象
- Echart中X轴数据过多时横向拉动展示
chart.setOption( { tooltip: { trigger: 'axis' }, toolbox: { feature: { saveAsImage: {} } }, grid: { ...
- [转]sourceforge文件下载过慢
sourceforge文件下载过慢,可以用下面网址镜像下载, 通过 下载Sourceforge等国内无法下载站点文件的另一种方法博文,好像主站点是 https://www.mirrorservice. ...
- 13. this关键字
1.this的概述 this关键字代表是对象的引用.也就是this在指向一个对象,所指向的对象就是调用该函数的对象引用. 2.this实例,初始化成员变 class Employee { privat ...
- Redis探索之路(一):Redis简介
一:NOSQL NotOnlySQL 反SQL运动,非关系型数据库(区别于Mysql关系型书库). 随着Web2.0兴起,“高性能”,“高并发”成为主流. NoSQL以key-value形式存储数据, ...
- grep命令 一 文本搜索工具
使用正则表达式搜索文本,并把匹配的行打印出来.使用权限是所有用户. 基本使用 grep [option] pattern filename: pattern如果是表达式或者超过两个单词的, 需要用引号 ...
- Delphi ADOQuery的属性 locktype、CursorLocation 、Filter、CursorType、CancelBatch 和 UpdateBatch
以下数据,部分来自网络的收集,部分为自己测试后的原创整理,希望对你有帮助,更新会注明日期. 1.locktype 指定用户打开数据集时对数据集的锁定级别: ltUnspecified 未指定锁定 ...
- ETL工具-Kattle:查询 HTTP/WebService
发送HTTP POST请求,获取返回内容. 发送HTTP GET请求,获取返回内容,可以从前面获取URL.参数名.参数值 通过Restful获取数据 通过webService获取数据 HTTP ...
- 基于bootstrap的时间选择插件daterangepicker以及汉化方法
双日历时间段选择插件 — daterangepicker是bootstrap框架后期的一个时间控件: 可以设定多个时间段选项:也可以自定义时间段:由用户自己选择起始时间和终止时间:时间段的最大跨度可以 ...
- 编译器报错: error LNK2001: unresolved external symbol "struct _ServiceDescriptorTable * KeServiceDescript
转自VC错误:http://www.vcerror.com/?p=10 问题描述: 编译器报错: error LNK2001: unresolved external symbol "str ...