题目:

  就不贴了吧···如题;

题解:

  后缀自动机模版题;没啥好说的····

代码:

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<ctime>
#include<cctype>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
const int N=;
int pre[N],step[N],son[N][],tot=,last=,root=;
char s[N];
struct suffix_auto
{
void extend(int ch)
{
int p=last,np=++tot;
step[tot]=step[last]+;
for(;p&&!son[p][ch];p=pre[p]) son[p][ch]=np;
if(!p) pre[np]=root;
else
{
int q=son[p][ch];
if(step[q]!=step[p]+)
{
int nq=++tot;
step[nq]=step[p]+;
memcpy(son[nq],son[q],sizeof(son[q]));
pre[nq]=pre[q];
pre[np]=pre[q]=nq;
for(;son[p][ch]==q;p=pre[p]) son[p][ch]=nq;
}
else
pre[np]=q;
}
last=np;
}
void build()
{
scanf("%s",s);
int len=strlen(s);
for(int i=;i<len;i++)
extend(s[i]-'A');
}
}automaton;
int main()
{
automaton.build();
scanf("%s",s);
int n=strlen(s);
int ans=,len=,p=;
for(int i=;i<n;i++)
{
int ch=s[i]-'A';
if(son[p][ch]) p=son[p][ch],len++;
else
{
while(p&&!son[p][ch]) p=pre[p];
if(!p) len=,p=root;
else
len=step[p]+,p=son[p][ch];
}
ans=max(ans,len);
}
cout<<ans<<endl;
return ;
}

  

最新文章

  1. 北京54全国80及WGS84坐标系的相互转换
  2. angularJs指令深度分析
  3. [javaSE] 反射-动态加载类
  4. php 通过API接口连接12306余票查询
  5. C++静态成员和静态成员函数
  6. servlet 生命周期
  7. 剑指架构师系列-Hibernate需要掌握的Annotation
  8. centos6.6安装redis服务安装redis服务,对于discuz来说可以作为缓存使用,减轻服务器压力
  9. 针对安卓java入门:数据类型
  10. HDOJ2015偶数求和
  11. 详解浏览器缓存机制与Apache设置缓存
  12. Journal.Today 1.0.0
  13. css3图片滤镜
  14. 五分钟学会centos配置gitlab
  15. mariadb笔记
  16. HTTP协议02-请求和响应的报文构成
  17. python3 读取dbf文件报错 UnicodeDecodeError: &#39;gbk&#39; codec can&#39;t decode
  18. python 读取excel数据
  19. BinaryReader 自己写序列化
  20. 各种版本的ST-LINK仿真器

热门文章

  1. nmon安装和使用介绍
  2. hihoCoder #1080 : 更为复杂的买卖房屋姿势 (线段树,多tag)
  3. COGS 2566. [51nod 1129] 字符串最大值
  4. codevs 2776 寻找代表元
  5. maven打包错误:No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
  6. UVA1660 Cable TV Network (无向图的点连通度)
  7. codeforces Gym 100338E Numbers (贪心,实现)
  8. SVN中的check out与export的区别
  9. C03 程序逻辑
  10. quartz测试类