Consider a string s that contains only the lowercase Latin alphabet. We define the "out" of a substring t of s
The present value is the number of occurrences of T in s multiplied by the length of T. Please find out the most in all palindrome strings of S
Large occurrence value. String length ≤300000
Palindrome Tree Template problem
Establish palindrome tree, then each node corresponds to an essentially different palindrome string, the number of occurrences is Cnti cnt_i
So violent traversal can
A string with a length of n n is the nature of a palindrome with a maximum of n N.
#include <bits/stdc++.h> using namespace std; #define for (I,n) for (int. i=1;i<=n;i++) #define FORK (I,k,n) for (int. i=k;i<=n;i++) #define REP (i,n) for (int i=0;i< n;i++) #define ForD (I,n) for (int. i=n;i;i--) #define FORKD (I,k,n) for (int. i=n;i>=k;i--) #define REPD (i,n) for (int i=n;i& gt;=0;i--) #define FORP (x) for (int p=pre[x];p, p=next[p]) #define FORPITER (x) for (int &p=iter[x];p; p=next[p]) #defin
E Lson (o<<1) #define Rson ((o<<1) +1) #define MEM (a) memset (A,0,sizeof (a));
#define MEMI (a) memset (A,127,sizeof (a));
#define MEMI (a) memset (A,128,sizeof (a)); #define INF (2139062143) #define F (100000007) #define PB push_back #define MP Make_pair #define MAXN (600000+10) typedef
Long Long ll;
LL Mul (ll A,ll b) {return (a*b)%F;} ll Add (ll A,ll b) {return (a+b)%F;} ll Sub (ll A,ll b) {return (A-b+llabs (-a)/f*f+f)%F;}
void Upd (ll &a,ll b) {a= (a%f+b%f)%F;}
namespace Palindromic_tree {int s[maxn],n;
int tot,next[maxn][26],link[maxn],len[maxn],last; int cnt[MAXN];
int newnode (int l) {len[tot]=l;
return tot++;
} void Mem () {mem (s) mem (next) Mem (link) mem (len) mem (CNT) n=tot=0; NewNode (0);
NewNode (-1); Link[0]=link[1]=1;
s[0]=27;
last=0;
} int GetNode (int x) {while (s[n-len[x]-1]! = S[n]) x=link[x];
return x;
} void Add (int c) {s[++n]=c;//cout<< "1";
int Cur=getnode (last);
if (!next[cur][c]) {int now=newnode (len[cur]+2);
int Tmp=getnode (link[cur]);
LINK[NOW]=NEXT[TMP][C];
NEXT[CUR][C] = now;
} Last=next[cur][c];
cnt[last]++;
} void Work () {REPD (I,tot) cnt[link[i]]+=cnt[i];
ll Ans=0;
Fork (I,2,tot) {Ans=max (ans,1ll*cnt[i]*len[i]);
} cout<<ans<<endl;
}} using namespace Palindromic_tree;
Char S[MAXN];
int N; int mAin () {//Freopen ("Bzoj3676.in", "R", stdin);//Freopen (". Out", "w", stdout);
Palindromic_tree::mem ();
scanf ("%s", s);
int N=strlen (S);
Rep (i,n) palindromic_tree::add (s[i]-' a ');
Palindromic_tree::work ();
return 0;
}