Match 基因匹配 题解(From luoguBlog)
2024-08-30 06:24:35
N<=20000!\(N^2\)的LCS要原地爆炸。
去您妈的优化考场上有分就行TLE60挺值了嘿嘿嘿
然而这显然是个板子 只不过像我这样见识短浅的蒟蒻不知道罢了
其实就是优化lcs
正解:
转化为lis后二分 复杂度nlogn。
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int n,s1[100010],s2[100010],pos[20010][8],num[20010]={0};
int tot=0,res[500010];
int ans=1,f[500010];
int main()
{
//freopen("lis.out","w",stdout);
cin>>n;
n*=5;
for(int i=1;i<=n;i++)scanf("%d",&s1[i]);
for(int i=1;i<=n;i++)scanf("%d",&s2[i]),pos[s2[i]][++num[s2[i]]]=i;
for(int i=1;i<=n;i++)
for(int j=1;j<=5;j++)res[++tot]=pos[s1[i]][5-j+1];
/*cout<<endl;
for(int i=1;i<=tot;i++)cout<<res[i]<<' ';
cout<<endl;*/
f[1]=res[1];
for(int i=2;i<=tot;i++)
{
if(res[i]>f[ans])
{
ans++;
f[ans]=res[i];
}
else
{
int loc=lower_bound(f+1,f+ans+1,res[i])-f;
f[loc]=res[i];
}
}
cout<<ans<<endl;
return 0;
}
最新文章
- zk 起别名时候碰到的问题
- hdfs的读写数据流
- <;转载>; OpenGL Projection Matrix
- Solr常用查询语法笔记
- Oracle数据库--SQL
- gitlab ce 中删除空项目之后,没有删除掉,访问500
- 19. Crontab
- Asp.net MVC + EF + Spring.Net 项目实践(四)
- XML文件的创建和解析笔记
- linux服务器使用yum安装nginx
- 使用Cordova打包Vue项目
- windows下用pycharm安装tensorflow简易教程
- python模块 - pywinauto(windows自动化安装软件)
- Logistic Regression(逻辑回归)
- Java多线程编程模式实战指南(二):Immutable Object模式
- html lang=";zh-cn";解决Mac版Firefox中文字体显示问题
- LeetCode赛题391----Perfect Rectangle
- Go语言内存分配机制
- 【JUC源码解析】AQS
- c++11之为什么C++11引入了std::ref?