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 ...
随机推荐
- docker 配置国内镜像源 linux/mac/windows
部分内容来自:http://guide.daocloud.io/dcs/daocloud-9153151.html 加速器官方DaoCloud承诺:加速器服务永久免费且无流量限制 使用前提:注册Dao ...
- LR11安装和配置教程
LoadRunner11安装教程 #安装包文件.汉化文件.破解文件,可以自行百科来获得,这边仅提供安装步骤. 1.前期准备1)安装前需要关闭防火墙及杀毒软件2)安装路径不能包含中文字符,同时需要以管理 ...
- mysqldumpslow及explain使用简介
- Python学习日志9月14日
今天早晨又没有专心致志的学习,我感觉我可能是累了,需要减轻学习的程度来调整一下咯.这几天装电脑弄的昏天暗地的,身体有点吃不消了.时间真是神奇的魔法,这半个月来,每隔几天都有想要改变策略的想法.今天早晨 ...
- 你是猴子请来的逗比么!IT跳槽大事件
3月招聘大战早已硝烟四起,互联网职场摇身一变成了跳蚤市场,猎头们告诉跳蚤们,跳不跳不是不问题,往哪儿跳才是重点,跳对了高薪期权都如过眼云烟.不过小编不得不说,劳资最痛恨那些跳槽的人啦!就因为加班 ...
- 标注偏置问题(Label Bias Problem)和HMM、MEMM、CRF模型比较<转>
转自http://blog.csdn.net/lskyne/article/details/8669301 路径1-1-1-1的概率:0.4*0.45*0.5=0.09 路径2-2-2-2的概率:0. ...
- IP数据包的校验和算法
1.算法思路: IP/ICMP/IGMP/TCP/UDP等协议的校验和算法都是相同的,算法如下: 在发送数据时,为了计算IP数据包的校验和.应该按如下步骤: (1)把IP数据包的校验和字段置为0: ( ...
- Fortran学习笔记4(循环语句)
Fortran学习笔记4 Fortran学习笔记4 逻辑运算 循环 Do语句 Do-While循环 循环控制 循环应用实例 逻辑运算 if命令需要和逻辑运算表达式搭配才能起到很好的效果.下面分别列出F ...
- 有关linux的GPG签名验证错误的解决方法。
GPG签名验证错误:由于没有公钥,下列签名无法进行验证: NO_PUBKEY 6AF0E1940624A220 找了下原因,虽然不知道原理,不过大概意思还是能才出来的,解决方法如下: gpg --ke ...
- Android目录结构
|ABI-- 应用程序二进制接口(application binary interface,ABI) |-- Makefile |-- bionic (bionic C库) ...