Jzoj4721 LCS
来源:互联网 发布:java电脑版86 编辑:程序博客网 时间:2024/06/08 10:36
给你2个没有重复元素的序列A,B,求LCS
我们将映射A[i]->i用在B上,对B求LIS即可,若A中没有B[i]直接跳过
#include<stdio.h>#include<string.h>#include<algorithm>#include<map>using namespace std;map<int,int> s;int f[300010];int main(){int n,m; scanf("%d%d",&n,&m);for(int x,i=0;i<n;++i){scanf("%d",&x);s[x]=i+1;}memset(f,127,sizeof f);for(int x,i=0;i<m;++i){scanf("%d",&x);x=s[x];if(x) *lower_bound(f,f+m,x)=x;}printf("%d\n",lower_bound(f,f+m,0x7f7f7f7f)-f);}
阅读全文
1 0
- Jzoj4721 LCS
- JZOJ4721 NlogN的LCS
- LCS
- LCS
- lcs
- LCS
- LCS
- LCS
- LCS
- LCS
- LCS
- LCS
- lcs
- LCS
- LCS
- lcs
- LCS
- LCS
- 将DIB/bitmap读入内存并转为 halcon hobject
- c++中string用法
- 静态链表
- JavaNote5
- 1003. 我要通过!(20)
- Jzoj4721 LCS
- 字符串的匹配--cookbook读书笔记
- Single Element in a Sorted Array
- SpringMVC源码剖析(二)- DispatcherServlet的前世今生
- Redis面向互联网的解决方案
- 侧滑菜单(抽屉效果)DrawerLayout实现原理
- ZooKeeper实现分布式队列
- 硬件访问服务
- 2017年10月14日 第五次总结