Greatest Common Increasing Subsequence

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 3649    Accepted Submission(s): 1147

Problem Description
This is a problem from ZOJ 2432.To make it easyer,you just need output the length of the subsequence.
 
Input
Each sequence is described with M - its length (1 <= M <= 500) and M integer numbers Ai (-2^31 <= Ai < 2^31) - the sequence itself.
 
Output
output 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 <iostream>
#include <cstdio>
#include <cstring>
#define clr(x,y) memset(x,y,sizeof(x))
using namespace std;
int a[],b[],ans[],an,bn;
int work()
{
memset(ans,,sizeof(ans));
int i,j,t,maxa,maxan=;
for(i=; i<=an; i++)
{
maxa=;
for(j=; j<=bn; j++)
{
if(a[i]>b[j]&&ans[j]>maxa)maxa=ans[j];
if(a[i]==b[j]&&ans[j]<maxa+)
ans[j]=maxa+;
}
}
for(i=;i<=bn;i++)
if(ans[i]>maxan)maxan=ans[i];
return maxan;
}
int main()
{
int t,i;
scanf("%d",&t);
while(t--)
{
scanf("%d",&an);
for(i=; i<=an; i++)scanf("%d",&a[i]);
scanf("%d",&bn);
for(i=; i<=bn; i++)scanf("%d",&b[i]);
printf("%d\n",work());
if(t)printf("\n");
}
}
Source

Greatest Common Increasing Subsequence hdu1423的更多相关文章

  1. HDU1423:Greatest Common Increasing Subsequence(LICS)

    Problem Description This is a problem from ZOJ 2432.To make it easyer,you just need output the lengt ...

  2. HDU 1423 Greatest Common Increasing Subsequence LCIS

    题目链接: 题目 Greatest Common Increasing Subsequence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: ...

  3. POJ 2127 Greatest Common Increasing Subsequence -- 动态规划

    题目地址:http://poj.org/problem?id=2127 Description You are given two sequences of integer numbers. Writ ...

  4. HDOJ 1423 Greatest Common Increasing Subsequence -- 动态规划

    题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1423 Problem Description This is a problem from ZOJ 2 ...

  5. ZOJ 2432 Greatest Common Increasing Subsequence(最长公共上升子序列+路径打印)

    Greatest Common Increasing Subsequence 题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problem ...

  6. HDU 1423 Greatest Common Increasing Subsequence(最长公共上升LCIS)

    HDU 1423 Greatest Common Increasing Subsequence(最长公共上升LCIS) http://acm.hdu.edu.cn/showproblem.php?pi ...

  7. POJ 2127 Greatest Common Increasing Subsequence

    You are given two sequences of integer numbers. Write a program to determine their common increasing ...

  8. HDUOJ ---1423 Greatest Common Increasing Subsequence(LCS)

    Greatest Common Increasing Subsequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536 ...

  9. 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 ...

随机推荐

  1. Element is not clickable at point error in chrome

    I see this only in Chrome. The full error message reads: "org.openqa.selenium.WebDriverExceptio ...

  2. 学习js的点点滴滴记录

    从安装完node.js后(里面自带了npm), 每个模块下都有个 package.json文件,在这个目录下打开cmd后 输入npm install 就是按照package.json里面的内容进行安装 ...

  3. .net分布式压力测试工具(Beetle.DT)

    肯定有人会问为什么会写这样一个开源工具?和现有的有什么差别?不过对于一个程序员来说写东西还真不需要理由的:),主要原因是工作有点闲(开玩笑),不过说实话一个程员怎可能会停止写代码呢(作为一个奔4的程序 ...

  4. Spark Mllib框架1

    1. 概述 1.1 功能 MLlib是Spark的机器学习(machine learing)库,其目标是使得机器学习的使用更加方便和简单,其具有如下功能: ML算法:常用的学习算法,包括分类.回归.聚 ...

  5. 安装sklearn过程

    sklearn是scikit-learn的简称,诸多python工具包都需要这个库 安装顺序: wheel numpy scipy sklearn 因为这个库一直安装不好,都没有动力继续深造机器学习了 ...

  6. 9-9害死人不偿命的(3n+1)猜想

    1001. 害死人不偿命的(3n+1)猜想 (15) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 卡拉兹(Ca ...

  7. JavaScript--我发现,原来你是这样的JS(基础概念--躯壳,不妨从中文角度看js)

    介绍 这是红宝书(JavaScript高级程序设计 3版)的读书笔记第二篇(基础概念--躯壳篇),有着部分第三章的知识内容,当然其中还有我个人的理解.红宝书这本书可以说是难啃的,要看完不容易,挺厚的, ...

  8. Visual Studio2017数据库数据比较

    一.前言 上一篇文章我们介绍了如何使用VS2017对SSMS数据库进行架构比较.这一篇文章我们将继续介绍如何对SSMS数据库的数据进行比较.数据的比较也是很常见的,比如我们要比较当前版本的数据库相对上 ...

  9. ln命令详解

    ln命令 (全称:link) ln命令用来为文件创建一个连接,类似于Windows的快捷方式,连接类型分为硬连接和软连接(符号连接)两种,默认的连接类型是硬连接.如果要创建符号连接必须使用" ...

  10. 【★】KMP算法完整教程

    KMP算法完整教程 全称:                               Knuth_Morris_Pratt Algorithm(KMP算法) 类型:                 ...