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 ...
随机推荐
- ASP.NET Core模块化前后端分离快速开发框架介绍之4、模块化实现思路
源码 GitHub:https://github.com/iamoldli/NetModular 演示地址 地址:https://nm.iamoldli.com 账户:admin 密码:admin 前 ...
- 《从0到1学习Flink》—— Flink 写入数据到 ElasticSearch
前言 前面 FLink 的文章中我们已经介绍了说 Flink 已经有很多自带的 Connector. 1.<从0到1学习Flink>-- Data Source 介绍 2.<从0到1 ...
- SublimeText相关配置
安转插件:案例格式化HTML代码,需要安装插件,具体安装步骤如下: 1.打开菜单->首选项->插件控制,输入 install package 2.等待程序进入插件管理功能,再输入插件名称: ...
- app开发,H5+CSS3页面布局小tips
1.inline-block使用后带来的间隔影响 2.竖线的处理 3.ssh公匙 4.星星组件的巧妙用法 5.api.js的$api对象与 安卓原生引擎的api对象,均相当于jQuery的$对象 6. ...
- 《译》准备做一些 AR/增强现实的 翻译
中文这方面资料实在少之又少. 准备做一些这方面翻译,关注于Vuforia, Unity3d, Hololens等方面. 如有问题.建议,随时联系.Fell free ton contact me.
- iBrand 教程:Xshell 软件安装过程截图及配置
下载 教程中使用的相关软件下载网盘: https://pan.baidu.com/s/1bqVD5MJ 密码:4lku 安装 请右键以管理员身份运行进行软件安装,安装过程如下: 配置 安装完成并运行软 ...
- JavaScript-判断语句(if...else)
语法: if(条件) { 条件成立时执行的代码 } else { 条件不成立时执行的代码 } 假设我们通过年龄来判断是否为成年人,如年龄大于等于18岁,是成年人,否则不是成年人.代码表示如下: < ...
- Python 随笔之Redis
Python学习记录 ——redis 2018-03-07 Redis是一个开源的使用ANSI C语言编写.支持网络.可基于内存亦可持久化的日志型.Key-Value数据库,并提供多种语言的API.从 ...
- JQUERY操作JSON数组添加新的属性和值
语法: var data = {}; data["Order"] =order; data["Sort"] = sort; 但是需要注意的是,如果data后面还 ...
- Android(java)学习笔记96:layout_weight使用注意事项
1. android:layout_weight使用说明: layout_weight是权重的意思,也就是各个控件所占的比重,用在LinearLayout布局中.当我们使用layout_weight的 ...