HDUOJ ---1423 Greatest Common Increasing Subsequence(LCS)
Greatest Common Increasing Subsequence
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 3460 Accepted Submission(s): 1092
//增长lcs algorithm
#include<stdio.h>
#include<string.h>
#define maxn 505
int aa[maxn],bb[maxn];
int lcs[maxn];
int main()
{
int test,na,nb,i,j,maxc,res;
scanf("%d",&test);
while(test--)
{
scanf("%d",&na);
for(i=;i<=na;i++)
scanf("%d",aa+i);
scanf("%d",&nb);
for(j=;j<=nb;j++)
scanf("%d",bb+j);
memset(lcs,,sizeof(lcs));
for(i=;i<=na;i++)
{
maxc=;
for(j=;j<=nb;j++)
{
if(aa[i]==bb[j]&&lcs[j]<maxc+)
lcs[j]=maxc+;
if(aa[i]>bb[j]&&maxc<lcs[j])
maxc=lcs[j];
}
}
res=;
for(i=;i<=nb;i++)
if(res<lcs[i])res=lcs[i];
printf("%d\n",res);
if(test) putchar();
}
return ;
}
HDUOJ ---1423 Greatest Common Increasing Subsequence(LCS)的更多相关文章
- HDU 1423 Greatest Common Increasing Subsequence(LCIS)
Greatest Common Increasing Subsequenc Problem Description This is a problem from ZOJ 2432.To make it ...
- 1423 Greatest Common Increasing Subsequence (LCIS)
讲解摘自百度; 最长公共上升子序列(LCIS)的O(n^2)算法? 预备知识:动态规划的基本思想,LCS,LIS.? 问题:字符串a,字符串b,求a和b的LCIS(最长公共上升子序列).? 首先我们可 ...
- HDU 1423 Greatest Common Increasing Subsequence(最长公共上升LCIS)
HDU 1423 Greatest Common Increasing Subsequence(最长公共上升LCIS) http://acm.hdu.edu.cn/showproblem.php?pi ...
- 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 ...
- 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
题目链接: 题目 Greatest Common Increasing Subsequence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: ...
- HDOJ 1423 Greatest Common Increasing Subsequence -- 动态规划
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1423 Problem Description This is a problem from ZOJ 2 ...
- HDU 1423 Greatest Common Increasing Subsequence(LICS入门,只要求出最长数)
Greatest Common Increasing Subsequence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536 ...
随机推荐
- 利用nginx加速web访问
起因---------- 在最近新系统的设计中对于首页打开速度的问题做了一些考虑,由于页面上还是以动态数据为主,所以简单的静态化数据可能并不行,所以需要从业务和技术结合的角度去考虑这个问题.由于有些数 ...
- JSP中解决中文乱码
<%@ page language="java" contentType="text/html;charset=gbk" pageEncoding=&qu ...
- C语言:将结构体数组的成绩按照从小到大进行排序。
#include<stdio.h> typedef struct student { char *name; int sno; int age; float score; }Student ...
- Mybatis映射实体改造和异常问题
现在WEB开发经常使用 Mybatis 作为持久化框架,在开发过程中,会在Java代码中构建实体类与数据库表字段相互映射, 下面提出一个关于映射实体优化的方案:通过链式编程实现给实例对象赋值. 参考代 ...
- (转)[Unity3D]UI方案及制作细节(NGUI/EZGUI/原生UI系统) 内附unused-assets清除实例
转载请留下本文原始链接,谢谢.本文会不定期更新维护,最近更新于2013.09.17. http://blog.sina.com.cn/s/blog_5b6cb9500101bplv.html ...
- Cocos Studio is EOL'd
Cocos Studio is EOL'd Cocos Studio has been EOL'd as of April 2016. There will be no more releases o ...
- 在Foreda8上试安装Apchehttpd-2.4.6.tar.gz
下文是我边试边做的记录,不保证内容的完整性和正确性. 由于我的Apsire机器是最简安装Foreda8,所以需要安装httpd,熟悉一遍也是很好的嘛. 我从网上搜罗并下载了apchehttpd-2.4 ...
- Office WORD如何在图片上添加文字
如图所示,在图片格式中选择图片衬于文字下方即可,这样看起来感觉就像在图片上直接加字一样,没有生硬的感觉. 最终效果: Word如何在图片上添加文字Word如何在图片上添加文字Word如何在图片上添加文 ...
- VIM经常使用操作
VIM使用 移动命令 按键 说明 h 左 l 右(小写L) j 下 k 上 w 移动到下一个单词 b 移动到上一个单词 进入插入模式 命令 说明 i 在当前光标处进行编辑 I 在行首插入 A 在行末插 ...
- 用 Eclipse 插件提高代码质量
如果能在构建代码前发现代码中潜在的问题会怎么样呢?很有趣的是,Eclipse 插件中就有这样的工具,比如 JDepend 和 CheckStyle,它们能帮您在软件问题暴露前发现这些问题.在 让开发自 ...