HDU 3068 最长回文子串(manacher算法)
来源:互联网 发布:linux 统计登录次数 编辑:程序博客网 时间:2024/05/01 16:48
//// main.cpp// Richard//// Created by 邵金杰 on 16/9/27.// Copyright © 2016年 邵金杰. All rights reserved.//#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>using namespace std;const int maxn=110000+100;int p[maxn*2];char s[maxn*2];int main(){ while(scanf("%s",s)!=EOF) { int len=(int)strlen(s); for(int i=len;i>=0;i--){ s[i+i+2]=s[i]; s[i+i+1]='#'; } int pos=0,MaxRight=0; for(int i=2;i<2*len+1;i++){ if(p[pos]+pos>i) p[i]=min(p[pos*2-i],p[pos]+pos-i); else p[i]=1; while(s[i-p[i]]==s[i+p[i]]) p[i]++; if(i+p[i]>pos+p[pos]) pos=i; if(p[i]>MaxRight) MaxRight=p[i]; } cout<<MaxRight-1<<endl; } return 0;}
参考:点击打开链接
0 0
- hdu 3068 最长回文(最长回文子串 manacher算法)
- hdu 3068 最长回文子串 Manacher算法
- hdu 3068最长回文子串(manacher算法)
- POJ 3974 HDU 3068 最长回文子串 Manacher 算法
- HDU 3068 最长回文子串 (manacher算法详解)
- HDU 3068 最长回文子串(manacher算法)
- hdu 3068 最长回文子串 Manacher算法
- hdu 3068 最长回文子串 manacher
- 【最长回文子串 manacher】HDU 3068
- hdu 3068 最长回文(manacher&最长回文子串)
- HDU 3068 最长回文 Manacher算法O(n)回文子串算法
- hdu【最长回文子串——Manacher算法】POJ 3974/HDU 3068
- Manacher算法求最长回文子串
- Manacher算法求最长回文子串
- 最长回文子串(Manacher算法)
- Manacher算法 最长回文子串
- 最长回文子串的manacher算法
- 最长回文子串,Manacher算法
- [BZOJ2097][Usaco2010 Dec]Exercise 奶牛健美操(二分+树形dp+贪心)
- angularjs对象的复制与备份
- Git 分支管理(Eclipse)
- DS证据理论浅析
- Android 7.1代码地址
- HDU 3068 最长回文子串(manacher算法)
- visual studio项目调错 LINK : fatal error LNK1104: 无法打开文件“IlmImf.lib”
- VC 6.0 调试快捷键说明.
- c#23中设计模式
- Class内存小记
- 二分查找实现及其应用
- 【web】上机实验一
- web开发模式+三层架构与MVC
- HTML 4.01的标准和规范以及如何使用中文