博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
POJ 3261 Milk Patterns 可重叠的k次最长重复子串
阅读量:4204 次
发布时间:2019-05-26

本文共 1035 字,大约阅读时间需要 3 分钟。

后缀数组 的入门题。

先计算好SA和height数组。

然后二分答案。二分的时候,对height进行分组,看存不存在一组的大小大于等于k

////  main.cpp//  后缀数组////  Created by liuzhe on 17/2/5.//  Copyright © 2017年 my_code. All rights reserved.//#include 
#include
#include
#include
#include
using namespace std;const int maxn = 50010;int wa[maxn],wb[maxn],wv[maxn],ww[maxn];int sa[maxn],lcp[maxn],rank[maxn],rank1[maxn];int str[maxn];int t,nn;inline bool cmp(int *r,int a,int b,int len){ return r[a]==r[b]&&r[a+len]==r[b+len];}void construct_sa(int n,int m){ int i,j,p,*x=wa,*y=wb,*t; n++;//why? for(i=0;i
=0;i--) sa[--ww[x[i]]] = i; for(j=p=1;p
<<=1,m=p) { for(p=0,i=n-j;i
=j) y[p++] = sa[i]-j; } for(i=0;i
=0;i--) sa[--ww[wv[i]]] = y[i]; for(t=x,x=y,y=t,x[sa[0]]=0,p=i=1;i
0) h--; for(;j+h
=mid&&i
=t-1) { flag=1;break; } } if(flag) return 1; else return 0;}int main(){ while(scanf("%d%d",&nn,&t)!=-1) { for(int i=0;i
1) { int mid=(le+ri)>>1; if(judge(mid,nn)) le=mid; else ri=mid; } printf("%d\n",le); } return 0;}

转载地址:http://vjali.baihongyu.com/

你可能感兴趣的文章
数据库优化 SQL语句优化
查看>>
Spring 各个jar包的作用
查看>>
SpringMVC 出现ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
查看>>
SpringMVC 过滤器HiddenHttpMethodFilter
查看>>
SpringMVC 返回json数据报错IllegalArgumentException: No converter found for return value of type:xxx
查看>>
SpringMVC 基本配置文件
查看>>
Velocity 模板出现NestedIOException: Cannot find Velocity template for URL [layout.vm]
查看>>
Velocity 模板基本用法
查看>>
SpringMVC 使用总结
查看>>
Mybatis 出现Mapped Statements collection does not contain value for xxx
查看>>
Mybatis 解决字段名与实体类属性名不相同的冲突
查看>>
Mybatis Generator最完整配置详解
查看>>
Mybatis 一级缓存和二级缓存
查看>>
Hibernate 出现Unsupported major.minor version 52.0 [duplicate]
查看>>
Hibernate 使用Intellij IDEA自动生成.hbm.xml文件
查看>>
Hibernate 出现org.hibernate.MappingNotFoundException: resource:**.hbm.xml not found问题的解决方案
查看>>
Hibernate 注解使用总结
查看>>
JAVA 事务之JDBC事务、JTA事务和容器事务
查看>>
EJB 是什么
查看>>
Hibernate 异常StrategySelectionException: Unable to resolve name EhCacheRegionFactory
查看>>