回文树裸题拿来练板
#include<cstring>
#include<cstdio>
#include<iostream>
#define maxn 300021
#define LL long long
using namespace std;
int n,p,last,fail[maxn],ch[maxn][26],len[maxn],cnt[maxn];
int s[maxn],N;
char ss[maxn];
int get(int x){
while(s[n]!=s[n-len[x]-1])x=fail[x];
return x;
}
void insert(int c){
s[++n]=c;
int cur=get(last);
if(!ch[cur][c]){
len[p]=len[cur]+2;
fail[p]=ch[get(fail[cur])][c];
ch[cur][c]=p++;
}
last=ch[cur][c];
cnt[last]++;
}
int main(){
scanf("%s",ss);N=strlen(ss);
s[0]=-1;p=2;
len[1]=-1;fail[0]=1;
for(int i=0;i<N;i++)insert(ss[i]-'a');
LL ans=0;
for(int i=p-1;i>1;i--)cnt[fail[i]]+=cnt[i];
for(int i=2;i<p;i++)ans=max(ans,(LL)len[i]*cnt[i]);
printf("%lld",ans);
return 0;
}