Match 基因匹配 题解(From luoguBlog)
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;
}
Match 基因匹配 题解(From luoguBlog)的更多相关文章
- BZOJ1264: [AHOI2006]基因匹配Match
1264: [AHOI2006]基因匹配Match Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 541 Solved: 347[Submit][S ...
- bzoj 1264: [AHOI2006]基因匹配Match
1264: [AHOI2006]基因匹配Match Description 基因匹配(match) 卡卡昨天晚上做梦梦见他和可可来到了另外一个星球,这个星球上生物的DNA序列由无数种碱基排列而成(地球 ...
- 【BZOJ1264】[AHOI2006]基因匹配Match DP+树状数组
[BZOJ1264][AHOI2006]基因匹配Match Description 基因匹配(match) 卡卡昨天晚上做梦梦见他和可可来到了另外一个星球,这个星球上生物的DNA序列由无数种碱基排列而 ...
- BZOJ 1264: [AHOI2006]基因匹配Match 树状数组+DP
1264: [AHOI2006]基因匹配Match Description 基因匹配(match) 卡卡昨天晚上做梦梦见他和可可来到了另外一个星球,这个星球上生物的DNA序列由无数种碱基排列而成(地球 ...
- 1264: [AHOI2006]基因匹配Match(动态规划神题)
1264: [AHOI2006]基因匹配Match 题目:传送门 简要题意: 给出两个序列.每个序列都由n种不同的数字组成,保证每个序列种每种数字都会出现5次(位置不一定一样),也就是序列长度为5*n ...
- 1264: [AHOI2006]基因匹配Match
1264: [AHOI2006]基因匹配Match Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 982 Solved: 635[Submit][S ...
- bzoj 1264 [AHOI2006]基因匹配Match(DP+树状数组)
1264: [AHOI2006]基因匹配Match Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 793 Solved: 503[Submit][S ...
- BZOJ 1264: [AHOI2006]基因匹配Match( LCS )
序列最大长度2w * 5 = 10w, O(n²)的LCS会T.. LCS 只有当a[i] == b[j]时, 才能更新答案, 我们可以记录n个数在第一个序列中出现的5个位置, 然后从左往右扫第二个序 ...
- bzoj1264 [AHOI2006]基因匹配Match 树状数组+lcs
1264: [AHOI2006]基因匹配Match Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 1255 Solved: 835[Submit][ ...
随机推荐
- hdu 4971 多校10最大权闭合图
/* 很明显的最大权闭合图题 */ #include<stdio.h> #include<string.h> #include<queue> using names ...
- Debug : array type has incomplete element type
array type has incomplete element type extern struct SoundReport SoundList[32]; ///// 多写了 st ...
- printf()参数的处理
下面程序的输出为? #include <stdio.h> int main(void) { ,b=,c=; printf(),(c = c*)); ; } 答案是110..40..60 这 ...
- POJ 3304 segments 线段和直线相交
Segments Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 14178 Accepted: 4521 Descrip ...
- 修改 db_unique_name
在创建DB的时候 db_unique_name设置错了.本来我是想让 db_name=itid db_unique_name=itid1 不过想改回来很简单的. SQL> alter syste ...
- HDU 4891 The Great Pan (字符串处理)
题目链接:HDU 4891 The Great Pan 求一串字符有多少种不同的意思,当中关心'{','}'之间的'|'. 和'$','$'之间的空格,连续N个空格算N+1种. AC代码: #incl ...
- Eclipse如何导入第三方jar包
本文转自:http://blog.csdn.net/mazhaojuan/article/details/21403717 我们在用Eclipse开发程序的时候,经常要用到第三方jar包.引入jar ...
- Html5笔记 表格 布局
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- CodeForces 444C. DZY Loves Physics(枚举+水题)
转载请注明出处:http://blog.csdn.net/u012860063/article/details/37509207 题目链接:http://codeforces.com/contest/ ...
- extjs_07_combobox&tree&chart
1.combobox <%@ page language="java" import="java.util.*" pageEncoding="U ...