UVA 10635 Prince and Princess【LCS 问题转换为 LIS】
来源:互联网 发布:jsp添加java代码 编辑:程序博客网 时间:2024/04/27 00:16
题目链接:
http://acm.hust.edu.cn/vjudge/problem/visitOriginUrl.action?id=19051
题意:
有两个长度分别为
分析:
注意题目说的每个序列的元素各不相等,那么就能保证我们可以把序列A的元素用
有关
代码:
/************************************************************************* > File Name: 10635.cpp > Author: jiangyuzhu > Mail: 834138558@qq.com > Created Time: Sat 18 Jun 2016 08:57:43 PM CST ************************************************************************/#include<iostream>#include<cstdio>#include<cstring>#include<cmath>#include<queue>#include<stack>using namespace std;#define sa(n) scanf("%d", &(n));typedef pair<int, int>p;const int maxn = 250 + 5, mod = 1e9 + 7, oo = 0x3f3f3f3f;int a[maxn * maxn], b[maxn * maxn], nb[maxn * maxn];int pos[maxn * maxn];int dp[maxn * maxn];int main (void){ int t;sa(t); for(int kas = 1; kas <= t; kas++){ int n, p, q;sa(n);sa(p);sa(q); memset(pos, 0, sizeof(pos)); for(int i = 0; i <= p; i++){ sa(a[i]); pos[a[i]] = i; } memset(nb, 0, sizeof(nb)); for(int i = 0; i <= q; i++){ sa(b[i]); nb[i] = pos[b[i]]; } memset(dp, 0x3f, sizeof(dp)); for(int i = 0; i <= q; i++){ *lower_bound(dp, dp + q + 1, nb[i]) = nb[i]; } int ans = lower_bound(dp, dp + q + 1, oo) - dp; printf("Case %d: %d\n", kas, ans); } return 0;}
0 0
- UVA 10635 Prince and Princess【LCS 问题转换为 LIS】
- UVA 10635 - Prince and Princess ( LCS 转换为LIS )
- uva 10635 Prince and Princess (将LCS 转化为 LIS)
- UVA 10635 - Prince and Princess LCS转化为LIS
- UVA - 10635 - Prince and Princess (LCS转化为LIS)
- uva-10635 Prince and Princess LCS转化为LIS
- UVA 10635 Prince and Princess LCS转化为LIS *
- UVA 10635 Prince and Princess lcs--》lis
- Uva - 10635 - Prince and Princess(LCS转LIS)
- UVA 10635 Prince and Princess (LCS优化转LIS)
- UVa 10635 Prince and Princess / LCS 转 LIS
- uva 10635Prince and Princess (LCS转LIS)
- UVA 10635 - Prince and Princess (LCS转成LIS DP)
- UVA - 10635 Prince and Princess LCS转LIS
- UVa 10635 - Prince and Princess(LCS转LIS)
- uva 10635-Prince and Princess 【LIS 求解 LCS】
- 【UVA 10635】【LCS转化成LIS】 Prince and Princess
- UVA 10635 Prince and Princess(LCS转LIS)
- 操作系统-锁机制
- jQuery遍历
- cygwin安装Cygwin/X需要选择的包
- SecureCRT简单的安装和激活教程
- DbUtil组件
- UVA 10635 Prince and Princess【LCS 问题转换为 LIS】
- Android输入事件从读取到分发二:谁在循环监听事件的到来
- 哲学家就餐问题
- 设计模式——单例模式C++实现
- Trie树:应用于统计和排序
- Redux 学习笔记(一)
- 将数组的后面m个数移动为前面m个数
- LSA潜在语义分析
- linux 中的/和~