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 ...
随机推荐
- JUC 一 FutureTask
java.util.concurrent public class FutureTask<V> implements RunnableFuture<V> 简介 FutureTa ...
- spring boot 项目启动无法访问,排查
查看docker日志,后台应用正常启动,定时任务正常执行,但是前端无法访问到后端接口,点击提示系统错误,解压出项目二级域名,访问域名,报错:Kong Error,说明Kong路由转发没有绑定项目端口, ...
- 【基础】Hint控制语句执行
mysql常用的hint对于经常使用oracle的朋友可能知道,oracle的hint功能种类很多,对于优化sql语句提供了很多方法.同样,在mysql里,也有类似的hint功能.下面介绍一些常用的. ...
- JavaWeb学习篇之----EL表达式详解
我们之前的几篇文章中都提到了一个EL表达式,那么这个EL表达式到底是什么东东呢?为什么用处那么大,下面我们就来看看EL表达式的相关内容 EL表达式简介: EL 全名为Expression Langua ...
- bzoj1012题解
[解题思路] 强制在线线段树/树状数组,没什么好说的..复杂度O(mlog2m)(线段树)或O(mlog22m)(树状数组). [参考代码] (还naive的时候写的zkw真是翔..) #includ ...
- NX二次开发-NXOpen中Point3d类型转换成point类型
NX9+VS2012 #include <NXOpen/NXObject.hxx> #include <NXOpen/Part.hxx> #include <NXOpen ...
- Spring-Security (学习记录七)--实现FilterInvocationSecurityMetadataSource的类将无法切入声明式事物
目录 1 查看继承关系 2 说明 3 查看源码: 实现了FilterInvocationSecurityMetadataSource 的类将无法切入声明式事物. 原因: 1 查看继承关系 先查看Fil ...
- javascript html jquery 入门
就开发难易程度来说,现在普遍使用jquery,本人学习jquery html css时间不长,以前写过Flex. CSS+JS+HTML组成HTML开发三驾马车.学习js开发我认为怎么入门十分重要.根 ...
- Windows内核驱动开发入门学习资料
声明:本文所描述的所有资料和源码均搜集自互联网,版权归原始作者所有,所以在引用资料时我尽量注明原始作者和出处:本文所搜集资料也仅供同学们学习之用,由于用作其他用途引起的责任纠纷,本人不负任何责任.(本 ...
- 剑指offer——03替换空格
题目描述 请实现一个函数,将一个字符串中的每个空格替换成“%20”.例如,当字符串为We Are Happy.则经过替换之后的字符串为We%20Are%20Happy. 注意事项: <剑指o ...