HDU 1423 Greatest Common Increasing Subsequence(LCIS)
Greatest Common Increasing Subsequenc
#include <cstdio>
#include <iostream>
#define N 607
#include <cstring>
using namespace std;
int n,m,T,ans;
int f[N][N],a[N],b[N]; inline int max(int a,int b) {return a>b?a:b;} void Init(){
scanf("%d",&n);
for (int i=;i<=n;i++) scanf("%d",&a[i]);
scanf("%d",&m);
for (int i=;i<=m;i++) scanf("%d",&b[i]);
} void Dp(){
memset(f,,sizeof(f));
for (int i=;i<=n;i++){
int val=;
if (b[]<a[i]) val=f[i-][];
for (int j=;j<=m;j++){
if (a[i]==b[j]) f[i][j]=val+;
else f[i][j]=f[i-][j];
if (a[i]>b[j]) val=max(val,f[i-][j]);
}
}
ans=;
for (int i=;i<=n;i++) ans=max(f[n][i],ans);
} int main(){
scanf("%d",&T);
for(;T--;){
Init();
Dp();
printf("%d\n",ans);
if (T) printf("\n");
}
}
HDU 1423 Greatest Common Increasing Subsequence(LCIS)的更多相关文章
- 1423 Greatest Common Increasing Subsequence (LCIS)
讲解摘自百度; 最长公共上升子序列(LCIS)的O(n^2)算法? 预备知识:动态规划的基本思想,LCS,LIS.? 问题:字符串a,字符串b,求a和b的LCIS(最长公共上升子序列).? 首先我们可 ...
- HDUOJ ---1423 Greatest Common Increasing Subsequence(LCS)
Greatest Common Increasing Subsequence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536 ...
- 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 LCIS
题目链接: 题目 Greatest Common Increasing Subsequence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: ...
- 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 看这个博客 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 ...
- 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 ...
随机推荐
- .net 记录
Stack Overflow 2016最新架构探秘 http://www.infoq.com/cn/news/2016/03/Stack-Overflow-architecture-insi#rd N ...
- mysql日常使用总结(持续更新中)
记录一些日常的mysql常用的使用, 方便随用随查. 一.表结构 1.1 查看表结构 方式1: 可以查看建表语句,完整的表结构. show create table table_name; 方式2:可 ...
- enable orgmode latex preview to support retina on mac
Table of Contents 1. enable orgmode latex preview to support retina on mac 1.1. get the proper versi ...
- servlet和jsp存值和取值的方式
在servlet和jsp中存值和取值的方式由两种 1种是setAttribute和getAttribute 2种是c:forEach
- python中函数的定义与调用
1.为什么要用函数? (1)代码重复太多(2)可读性差 使用函数的好处: (1)代码重用 (2)保持一致性,易维护 (2)可扩展性 2.初始函数定义与调用 函数的定义 def test(x): ...
- 十分钟玩转 jQuery、实例大全(参考自博主索宁)
十分钟玩转 jQuery.实例大全(参考自博主索宁) 一.简介 书写规则 支持链式操作: 在变量前加"$"符号(var $variable = jQuery 对象): 注:此规定并 ...
- TED:如何掌控你的自由时间以及让自己变得更好,这样就能看到爱情应有的样子
TED:如何掌控你的自由时间以及让自己变得更好,这样就能看到爱情应有的样子 一.<如何掌控你的自由时间> (1)时间管理的传统思维:守时和节省零散的时间.演讲者认为这个观点已经彻底落后. ...
- C# Dictionary的遍历
foreach (KeyValuePair<string, string> kvp in dic) { Console.WriteLine("key:{0},value:{1}& ...
- Eucalyptus简介
1.Eucalyptus是什么? Eucalyptus n.桉树 Eucalyptus is a Linux-based software architecture that implements ...
- 关于Mybatis的pagehelper使用遇到的坑
参考博客: https://blog.csdn.net/wzyxdwll/article/details/66473466 下面给出pagehelp使用的配置, 在springmvc中的配置: 下面是 ...