namacher裸题++
1 #include2 #include 3 #include 4 #include 5 #include 6 #define LL long long 7 using namespace std; 8 9 const int maxn=2333333;10 11 char s[maxn<<1],a[maxn];12 int len[maxn<<1];13 14 int manachar(char *p)15 {16 int l=0,n=strlen(p);17 s[l++]='$'; s[l++]='#';18 for (int i=0; i i) len[i]=min(len[pos*2-i],mx-i); else len[i]=1;24 while (s[i+len[i]]==s[i-len[i]]) len[i]++;25 ans=max(ans,len[i]);26 if (len[i]+i>mx) mx=i+len[i],pos=i;27 }28 return ans-1;29 }30 31 int main()32 {33 int T=0;34 while (scanf("%s",a)!=EOF)35 {36 if (a[0]=='E') break;37 printf("Case %d: %d\n",++T,manachar(a));38 }39 return 0;40 }