UVa 10635 - Prince and Princess(LCS转LIS)
来源:互联网 发布:2am 2pm 知乎 编辑:程序博客网 时间:2024/04/27 05:17
给出两个序列,第一个序列中的数不重复,求两个序列的LCS。
以为第一个序列的数不同,所以可以保存数在第一个序列中出现的顺序,然后删除第二个序列中不再第一个序列中的数,将剩下的数换成在第一个序列中出现的位置,对处理好的序列求LIS。
#include<cstdio>#include<cstring>#include<algorithm>using namespace std;const int inf=0x3f3f3f3f;const int maxn=62510;int s[maxn],num[maxn],d[maxn];int main(){ int t,tt=0;scanf("%d",&t); while(t--){ int n,p,q; scanf("%d%d%d",&n,&p,&q); memset(num,0,sizeof num); for(int i=1;i<=p+1;++i){ int x;scanf("%d",&x); num[x]=i; } n=0; for(int i=0;i<=q;++i){ int x;scanf("%d",&x); if(num[x]) s[n++]=num[x]; } fill(d,d+n,inf); for(int i=0;i<n;++i) *lower_bound(d,d+n,s[i])=s[i]; printf("Case %d: %d\n",++tt,int(lower_bound(d,d+n,inf)-d)); } 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 10635Prince 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 DP)
- uva 10635-Prince and Princess 【LIS 求解 LCS】
- uva-10635 Prince and Princess LCS转化为LIS
- UVA 10635 Prince and Princess【LCS 问题转换为 LIS】
- 【UVA 10635】【LCS转化成LIS】 Prince and Princess
- poj 1823 Hotel(线段树·区间更新·lazy tag)
- 32位机和64位机编程时应该注意些什么
- HDU2.2.5 三角形
- 不要死性不改
- Django之第一个app<15>
- UVa 10635 - Prince and Princess(LCS转LIS)
- listview实现自动向上滚动,快速滚动,和滚动条的一些设置
- 简单工厂方法,工厂方法,抽象工厂方法
- web开发的几道笔试题
- 字符串相关处理函数
- 编写一个方法,确定某字符串的所有排列组合
- 二进制安全
- android获取存储空间
- android:如何从照片中获取拍摄地址信息