csu1120 Lics(模板)
来源:互联网 发布:qq管家软件管理 编辑:程序博客网 时间:2024/06/06 04:51
题目链接:点击打开链接
求最长递增公共子序列长度
#include <stdio.h>#include <algorithm>#include <string.h>using namespace std;const int maxn=1e3+10;int n,m,a[maxn],b[maxn],dp[maxn][maxn];//a数组的长度n,b数组的长度为m,都是从1开始int LICS(){ int MAX,i,j; memset(dp,0,sizeof(dp)); for(i = 1; i<=n; i++) { MAX = 0; for(j = 1; j<=m; j++) { dp[i][j] = dp[i-1][j]; if(a[i]>b[j] && MAX<dp[i-1][j]) MAX = dp[i-1][j]; if(a[i]==b[j]) dp[i][j] = MAX+1; } } MAX = 0; for(i = 1; i<=m; i++) if(MAX<dp[n][i]) MAX = dp[n][i]; return MAX;}int main(){ int T,i; scanf("%d",&T); while(T--) { scanf("%d",&n); for(i=1;i<=n;i++)scanf("%d",&a[i]); scanf("%d",&m); for(i=1;i<=m;i++)scanf("%d",&b[i]); printf("%d\n",LICS()); }}
阅读全文
0 0
- csu1120 Lics(模板)
- CSU1120:病毒(LICS)
- csu 1120 病毒(LICS模板) 解题报告
- LICS
- HDOJ 题目1423 Greatest Common Increasing Subsequence(LICS)
- poj2127 Greatest Common Increasing Subsequence(LICS+路径)
- hdu 1423Greatest Common Increasing Subsequence(lics)
- 病毒(LICS 最长上升公共子序列)
- CSU 1120 病毒(最长公共递增子序列LICS)
- java最长上升连续子序列(LICS)
- LIS&LICS
- hdu1423 Lics
- CSU1120-病毒-DP/LCS/LIS
- POJ 题目2127 Greatest Common Increasing Subsequence(LICS,输出路径)
- HDOJ 题目4512 吉哥系列故事——完美队形I(LICS变形)
- hdu 4512 吉哥系列故事——完美队形I(LICS)
- 【poj 2127】Greatest Common Increasing Subsequence lics(输出答案坑死)
- hdu 1423 LICS
- opencv 头文件 包含 include 的问题
- android自定义权限
- js笔记
- Easylogging++源码分析
- React Native Could not expand ZIP
- csu1120 Lics(模板)
- HDU 6156 Palindrome Function(数位DP)
- Android LayoutInflater原理分析
- 分布式系统介绍
- tf.unstack的作用
- setitimer和sigaction函数写的每隔5秒在循环屏幕打印hello world
- opencv中头文件详解
- C语言结构体数组同时赋值的另类用法
- HDU 6154 CaoHaha's staff