hdu3068 Manacher模板
来源:互联网 发布:机顶盒刷linux 编辑:程序博客网 时间:2024/05/22 08:14
#include <iostream>#include <cstdio>#include <string>#include <cstring>#include <fstream>#include <algorithm>#include <cmath>#include <queue>#include <stack>#include <vector>#include <map>#include <set>#include <iomanip>using namespace std;//#pragma comment(linker, "/STACK:102400000,102400000")#define maxn 200005#define MOD 1000000007#define mem(a , b) memset(a , b , sizeof(a))#define LL long long#define ULL long longconst long long INF=0x3fffffff;#define N 110010char s[N*2],str[N*2];int n,p[N*2];void fun(){ int len=(int)strlen(s); str[0]='$';str[1]='#'; n=2; for(int i=0;i<len;i++) { str[n++]=s[i]; str[n++]='#'; } str[n]='\0';}void Manacher(){ int i,id,mx=0; for(i=1;i<n;i++) { if(mx > i) p[i]=min(p[2*id-i],p[id]+id-i); else p[i]=1; for(;str[i+p[i]] == str[i-p[i]];p[i]++) ; if(p[i]+i > mx) { mx=p[i]+i; id=i; } }}void work(){ int ans=-1; for(int i=1;i<n;i++) ans=max(ans,p[i]); printf("%d\n",ans-1);}int main(){ while(scanf("%s",s)!=EOF) { fun(); Manacher(); work(); } return 0;}
0 0
- hdu3068 Manacher模板
- hdu3068 manacher算法模板
- HDU3068 最长回文 manacher模板
- hdu3068 最长回文(Manacher模板)
- HDU3068最长回文 (Manacher模板)
- {Manacher}hdu3068
- manacher hdu3068
- hdu3068(Manacher)
- hdu3068 Manacher算法
- hdu3068(manacher算法)
- hdu3068(Manacher算法)
- 【HDU3068】最长回文【manacher】
- HDU3068 最长回文 manacher
- 【HDU3068】最长回文【Manacher】
- 最长回文 hdu3068 manacher
- Manacher HDU3068 最长回文
- manacher算法&hdu3068
- hdu3068 manacher模版
- Android快捷方式
- java异常体系
- Android Spinner
- 文章标题
- 蜜罐发展史
- hdu3068 Manacher模板
- Java Integer 判等误区
- iOS tableViewCell 代理
- 安卓Selector失效、无用的解决方案
- 漫谈程序员系列:咦,你也在混日子啊
- ELF格式详解
- MFC中按钮的图片的变化,静态/hover/press,利用GDI
- 自己整理的OkHttp工具——留存用
- Bundle传数据