Greatest Common Increasing Subsequence
/*HDU1423 最长公共递增*/
#include <stdio.h>
#include <string.h>
#include <iostream>
using namespace std;
#define N 550
int dp[N][N];
int s[N],t[N]; int main()
{
int t1;
while(scanf("%d",&t1)!=EOF)
{
while(t1--)
{
int n,m;
scanf("%d",&n);
for(int i=;i<=n;i++)
scanf("%d",&s[i]);
scanf("%d",&m);
for(int i=;i<=m;i++)
scanf("%d",&t[i]);
memset(dp,,sizeof(dp));
int mx=;
for(int i=;i<=n;i++)
{
mx=;
for(int j=;j<=m;j++)
{
dp[i][j] = dp[i-][j];
if( s[i]>t[j])
{
mx=dp[i-][j];
}
if( s[i] == t[j] )
{
dp[i][j]=mx+;
}
}
}
mx=-;
int id;
for(int i=;i<=m;i++)
if(dp[n][i]>mx)
{
mx=dp[n][i];
}
printf("%d\n",mx);
if(t1!=) printf("\n");
}
}
return ;
}
Greatest Common Increasing Subsequence的更多相关文章
- HDU 1423 Greatest Common Increasing Subsequence LCIS
题目链接: 题目 Greatest Common Increasing Subsequence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: ...
- POJ 2127 Greatest Common Increasing Subsequence -- 动态规划
题目地址:http://poj.org/problem?id=2127 Description You are given two sequences of integer numbers. Writ ...
- HDOJ 1423 Greatest Common Increasing Subsequence -- 动态规划
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1423 Problem Description This is a problem from ZOJ 2 ...
- ZOJ 2432 Greatest Common Increasing Subsequence(最长公共上升子序列+路径打印)
Greatest Common Increasing Subsequence 题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problem ...
- HDU 1423 Greatest Common Increasing Subsequence(最长公共上升LCIS)
HDU 1423 Greatest Common Increasing Subsequence(最长公共上升LCIS) http://acm.hdu.edu.cn/showproblem.php?pi ...
- 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 ...
- Greatest Common Increasing Subsequence hdu1423
Greatest Common Increasing Subsequence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536 ...
- POJ 2127 Greatest Common Increasing Subsequence
You are given two sequences of integer numbers. Write a program to determine their common increasing ...
- HDUOJ ---1423 Greatest Common Increasing Subsequence(LCS)
Greatest Common Increasing Subsequence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536 ...
- 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 ...
随机推荐
- MediaPlayer播放音频,也可以播放视频
使用MediaPlayer播放音频或者视频的最简单例子: JAVA代码部分: public class MediaPlayerStudy extends Activity { private Butt ...
- Struts 2再曝远程代码执行漏洞S2-037
导读今年4月份,Apache Stuts 2之上发现的S2-033远程代码执行漏洞,以迅雷不及掩耳之势席卷而来.其利用代码很快就在短时间内迅速传播.而且官方针对这个高危漏洞的修复方案还是无效的. 悲剧 ...
- Netty 服务端创建
参考:http://blog.csdn.net/suifeng3051/article/details/28861883?utm_source=tuicool&utm_medium=refer ...
- JAVA基础之sql模糊匹配、外键以及jsp中include的用法
一.SQL模糊匹配 适用于对字符串进行模糊搜索 格式: 字段名 Like '%关键词%' % 表示这个位置可有任意个字符(没有也可以) %关键词% 只要包含关键词就算 ...
- HQL的第一个程序
使用HQL查询数据库: 分为以下几个步骤 1获取query对象 //1获取query对象 String hql="FROM Employee e where e.salary>?&qu ...
- FZU Moon Game(几何)
Accept: 710 Submit: 2038 Time Limit: 1000 mSec Memory Limit : 32768 KB Problem Description Fa ...
- Ubuntu下编译C语言程序(同时给编译生成的文件命名)
1.创建c文件 test.c touch test.c 2.编写test.c vim test.c #include "stdio.h" int main(){ printf(&q ...
- 并发编程 - 进程 - 1.开启子进程的两种方式/2.查看pid/3.Process对象的其他属性或方法/4.守护进程
1.开启子进程的两种方式: # 方式1: from multiprocessing import Process import time def task(name): print('%s is ru ...
- NSUserDefaults保存对象数组报错
在使用NSUserDefaults的时候插入数据有时候会报以下错误:Attempt to set a non-property-list objec 这种错误的原因是插入了不识别的数据类型,NSUse ...
- (1.3.1)连接安全(连接实例与网络协议及TDS端点)
连接安全是sql server安全配置的第1道防线,它保证只有许可的客户端能够连接sql server,而且可以限制连接可用的通道(各种网络协议). 1.连接到sql server实例 sql ser ...