标签:eof return etc div -- clu man space char s
#include <bits/stdc++.h> using namespace std; char str[20005],str1[40005],len=0; int p[40005]; int manachar(){ int id=0,maxn=0,ans=0,j=1; str1[0]=‘@‘; for(int i=0;i<=len;i++){ str1[j++]=str[i]; str1[j++]=‘#‘; } str1[j]=0; for(int i=0;i<j;i++){ if(i<maxn) p[i]=max(maxn-i,p[2*id-i]); else p[i]=1; while(str1[i+p[i]]==str1[i-p[i]]) p[i]++; if(p[i]+i>maxn){ maxn=p[i]+i; id=i; } ans=max(ans,p[i]); } return ans-1; } int main(){ while((str[len]=getchar())!=EOF)len++; len--; cout<<manachar(); return 0; }
标签:eof return etc div -- clu man space char s
原文地址:http://www.cnblogs.com/HC-LittleJian/p/7811017.html