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;
}

最新文章

  1. zk 起别名时候碰到的问题
  2. hdfs的读写数据流
  3. &lt;转载&gt; OpenGL Projection Matrix
  4. Solr常用查询语法笔记
  5. Oracle数据库--SQL
  6. gitlab ce 中删除空项目之后,没有删除掉,访问500
  7. 19. Crontab
  8. Asp.net MVC + EF + Spring.Net 项目实践(四)
  9. XML文件的创建和解析笔记
  10. linux服务器使用yum安装nginx
  11. 使用Cordova打包Vue项目
  12. windows下用pycharm安装tensorflow简易教程
  13. python模块 - pywinauto(windows自动化安装软件)
  14. Logistic Regression(逻辑回归)
  15. Java多线程编程模式实战指南(二):Immutable Object模式
  16. html lang=&quot;zh-cn&quot;解决Mac版Firefox中文字体显示问题
  17. LeetCode赛题391----Perfect Rectangle
  18. Go语言内存分配机制
  19. 【JUC源码解析】AQS
  20. c++11之为什么C++11引入了std::ref?

热门文章

  1. hdu 2527哈夫曼树(二叉树的运用)
  2. angular的又一本好书
  3. A. Treasure Hunt Codeforces 线性代数
  4. N天学习一个Linux命令之top
  5. [转]十五天精通WCF——第五天 你需要了解的三个小技巧
  6. java枚举怎么用的
  7. 解释为什么word2vec也被称作deep learning
  8. 2015 Changchun Regional
  9. HDU 5200 脑洞题 离线
  10. 笔记本光驱位换SSD固态硬盘之硬盘格式化