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 ...
随机推荐
- Laravel Route Resource 方法
新增的 resource 方法将遵从 RESTful 架构为用户资源生成路由.该方法接收两个参数,第一个参数为资源名称,第二个参数为控制器名称. Route::resource('users', 'U ...
- 16. 继承(extends)
1.语法 class 类名1 extends 类名2{ //成员变量和成员方法 } 2.继承要注意的事项: 1)千万不要为了减少重复代码而去继承,只有真正存在着继承关系的时候才去继承. 2)父类私有的 ...
- 第一类和第二类Stirling数
做了老是忘…… 实际问题: 找维基百科.百度百科…… 第一类Stirling数 n个元素构成m个圆排列 S(n,m)=S(n-1,m-1)+(n-1)*S(n-1,m) 初始 S(0,0)=1 S(n ...
- C#/.NET 实现的多屏联动,多屏共享,显示到指定屏幕上
假设我现在有4个屏幕,希望实现主屏幕在操作的时候,其他3块屏幕可以实时联动,并且延迟在1s以内. 正常情况下,我们可以借助于各个远程软件实现效果,但是有时候会显得笨重麻烦,假如只有一台服务器呢?? S ...
- 区别 |python-pandas库set_index、reset_index用法区别
1.set_index() 作用:DataFrame可以通过set_index方法,将普通列设置为单索引/复合索引. 格式:DataFrame.set_index(keys, drop=True, a ...
- 使用threading模块创建线程
#_author:来童星#date:2019/12/17#使用threading模块创建线程import threading,timedef process(): for i in range(3): ...
- poj1637Sightseeing tour
传送门 网络流解混合图欧拉回路,以前xy讲过,但是我一直没写. 把无向边随意定向,每个点权值为出度减入度,权值为奇数无解,权值大于0的从s向其连权值/2的边,小于0的向t连-权值/2的边,原图中无向图 ...
- ElasticSearch 索引查询使用指南
1.检测集群是否健康,我们通常用下面的命令.确保9200端口号可用: http://localhost:9200/_cat/health?v 或者 http://localhost:9200/_clu ...
- 20140403 opencv GPU安装
1. 查看本机配置,查看显卡类型是否支持NVIDIA GPU,本机显卡为NVIDIA GeForce 8400 GS: 2. 从http://www.nvidia.cn/Download/inde ...
- 利用Python,方便局域网内上传下载文件
因为一直在用windows系统,最近需要用到linux的服务器,两个电脑之间总是需要来回拷贝文件 这样使得很繁琐,之前一直在用Python,开启一个简单的服务器,可以在另外一台同一局域网下的电脑,在线 ...