HDU 1423 Greatest Common Increasing Subsequence
来源:互联网 发布:淘宝上取消了分流 编辑:程序博客网 时间:2024/05/21 09:30
经典LIS问题,去最长上升公共子序(要注意输出格式)
#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;const int maxm=505;int a[maxm];int b[maxm];int dp[maxm][maxm];int n,m;int LIS(){ int i,j; int ans=-1; for(i=1; i<=n; i++) { int M=0; for(j=1; j<=m; j++) { if(M<dp[i-1][j]&&a[i]>b[j]) { M=dp[i-1][j]; } if(a[i]!=b[j]) { dp[i][j]=dp[i-1][j]; } else { dp[i][j]=M+1; } if(dp[i][j]>ans) ans=dp[i][j]; } } return ans;}int main(){ int t; scanf("%d",&t); while(t--) { memset(dp,0,sizeof(dp)); scanf("%d",&n); int i,j; 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",LIS()); if(t) printf("\n"); } return 0;}
0 0
- HDU 1423 Greatest Common Increasing Subsequence
- hdu 1423 greatest common increasing subsequence
- hdu 1423 Greatest Common Increasing Subsequence
- Hdu 1423 Greatest Common Increasing Subsequence
- hdu 1423 Greatest Common Increasing Subsequence
- hdu 1423 Greatest Common Increasing Subsequence
- HDU 1423 Greatest Common Increasing Subsequence
- HDU 1423 Greatest Common Increasing Subsequence
- hdu 1423 Greatest Common Increasing Subsequence(LIS)
- HDU 1423--Greatest Common Increasing Subsequence【LCIS】
- HDU 1423 Greatest Common Increasing Subsequence
- HDU 1423 Greatest Common Increasing Subsequence
- HDU 1423 Greatest Common Increasing Subsequence
- HDU 1423 Greatest Common Increasing Subsequence(DP)
- HDU 1423 Greatest Common Increasing Subsequence(LCIS)
- HDU 1423 Greatest Common Increasing Subsequence
- HDU 1423 Greatest Common Increasing Subsequence (LCIS)
- hdu 1423 Greatest Common Increasing Subsequence (最长上升子序列)
- java 大数
- 数据结构_单链表的逆置
- 玩转Ubuntu
- 抽象工厂
- Redis, Memcache, Mysql区别
- HDU 1423 Greatest Common Increasing Subsequence
- HDU 1873 看病要排队 优先队列
- UI_UITableView _新知识_02
- 模板-最小生成树计数
- bzoj1375[Baltic2002]Bicriterial routing 双调路径
- POJ 3237 Tree 树链剖分 边权
- C++Primer第五版 7.5.2节练习
- Pro/E环境下的弧齿锥齿轮三维参数化造型
- 视频编解码学习之一:理论基础