模板题。问你一个串里最大的值(回文子串*出现次数)
/* gyt
Live up to every day */
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<cstring>
#include<queue>
#include<set>
#include<string>
#include<map>
#include <time.h>
#define PI acos(-1)
using namespace std;
typedef long long ll;
typedef double db;
const int maxn = 1e6+;
const int sigma=;
const ll mod = ;
const int INF = 0x3f3f3f;
const db eps = 1e-;
struct ptree{
char s[maxn];
int next[maxn][sigma], fail[maxn], cnt[maxn], len[maxn];
int last, n, p;
ll res;
inline int newnode(int l) {
cnt[p]=;
len[p]=l;
return p++;
}
inline void init() {
n=, p=, last=;
memset(next, 0, sizeof(next));
memset(cnt, 0, sizeof(cnt));
memset(len, 0, sizeof(len));
memset(fail, 0, sizeof(fail));
newnode(), newnode(-);
s[n]=-;
fail[]=;
//cout<<n<<" "<<p<<" "<<last<<endl;
}
inline int FL(int x) {
while(s[n-len[x]-]!=s[n]) x=fail[x];
return x;
}
void add(char c) {
c-='a';
s[++n]=c;
int cur=FL(last);
if (!next[cur][c]) {
int now=newnode(len[cur]+);
fail[now]=next[FL(fail[cur])][c];
next[cur][c]=now;
}
last=next[cur][c];
++cnt[last];
}
inline ll countt() {
ll pk=;
for (int i=p-; ~i; --i) {
cnt[fail[i]]+=cnt[i];
pk=max(pk, (ll)cnt[i]*(ll)len[i]);
}
return pk;
}
}p;
char s[maxn];
void solve(){
scanf("%s",s);
int len=strlen(s);
p.init();
for(int i=;i<len;i++)
p.add(s[i]);
printf("%lld\n",p.countt());
}
int main() {
int t = ;
// freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
//scanf("%d", &t);
while(t--)
solve();
return ;
}