HDU 1423 Greatest Common Increasing Subsequence ——动态规划
好久以前的坑了。
最长公共上升子序列。
没什么好说的,自己太菜了
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define F(i,j,k) for (int i=j;i<=k;++i)
#define D(i,j,k) for (int i=j;i>=k;--i)
#define ll long long
#define maxn 505
#define mp make_pair int t,n,m,a[maxn],b[maxn],f[maxn][maxn],ans; int main()
{
scanf("%d",&t);
while (t--)
{
ans=0;
scanf("%d",&n);F(i,1,n)scanf("%d",&a[i]);
scanf("%d",&m);F(i,1,m)scanf("%d",&b[i]);
memset(f,0,sizeof f);
F(i,1,n)
{
int tmp=0;
for (int j=1;j<=m;++j)
{
f[i][j]=f[i-1][j];
if (b[j]<a[i]) tmp=max(f[i][j],tmp);
if (a[i]==b[j]) f[i][j]=max(f[i][j],tmp+1);
}
}
F(i,1,m) ans=max(ans,f[n][i]);
printf("%d\n",ans);
if (t) printf("\n");
}
}
HDU 1423 Greatest Common Increasing Subsequence ——动态规划的更多相关文章
- 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 -- 动态规划
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1423 Problem Description This is a problem from ZOJ 2 ...
- 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(LCIS)
Greatest Common Increasing Subsequenc Problem Description This is a problem from ZOJ 2432.To make it ...
- 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 ...
- 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 ...
- HDUOJ ---1423 Greatest Common Increasing Subsequence(LCS)
Greatest Common Increasing Subsequence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536 ...
随机推荐
- AndroidStudio进行Build时出现DexArchiveMergerException异常的解决办法
今天在AndroidStudio中导入了一个项目,编译的时候没有什么问题,但是在执行Rebuild Project 和 Build APK(s)时报错了,提示: Error:Execution fai ...
- Volley源码解析(三) 有缓存机制的情况走缓存请求的源码分析
Volley源码解析(三) 有缓存机制的情况走缓存请求的源码分析 Volley之所以高效好用,一个在于请求重试策略,一个就在于请求结果缓存. 通过上一篇文章http://www.cnblogs.com ...
- Windows上SVN服务器搭建【转】
Subversion是优秀的版本控制工具,其具体的的优点和详细介绍,这里就不再多说.本文介绍Windows上 VisualSVN server 服务端和 TortoiseSVN客户端搭配使用: 现在S ...
- POJ 2152 Fire (树形DP,经典)
题意:给定一棵n个节点的树,要在某些点上建设消防站,使得所有点都能够通过某个消防站解决消防问题,但是每个点的建站费用不同,能够保证该点安全的消防站的距离上限也不同.给定每个点的建站费用以及最远的消防站 ...
- gunzip
gunzip——解压缩.gz的压缩文件 GNU unzip 命令所在路径:/bin/gunzip 示例1: # gunzip services.gz 解压缩当前目录下的services.gz文件,执行 ...
- SQLite C/C++ 教程
目录 1安装 2 C/C++ Interface APIs 3连接到数据库 4创建表 5插入操作 6更新操作 7删除操作 安装 在我们开始使用SQLite在C / C++程序,我们需要确保SQLite ...
- block的优势
https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/Blocks/Articles/bxOvervie ...
- (五)VMware Harbor 部署之SSL
转自:https://www.cnblogs.com/Rcsec/p/8479728.html 1 .签名证书与自签名证书 签名证书:由权威颁发机构颁发给服务器或者个人用于证明自己身份的东西. 自签名 ...
- EXTJS中文乱码
在<head>中加入 <meta http-equiv="Content-Type" content="text/html; charset=GB231 ...
- shell脚本,计算创建100个文件所用多少时间。
[root@localhost mulu]# ls [root@localhost mulu]# `; do touch file$i; done real 0m0.104s user 0m0.012 ...