This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define N 300100
using namespace std;
long long S[N],ans,c,m;
struct T {
long long t[N][26],li[N],len[N],oc[N],sz,lst;
T(){sz=li[0]=li[1]=1;len[1]=-1;}
void add(int c) {
int p = lst;S[++m]=c;
while (S[m-1-len[p]]-c)p=li[p];
if (!t[p][c]) {
int q=li[p];
while(S[m-len[q]-1]-c)q=li[q];
li[++sz]=t[q][c];
len[t[p][c]=sz]=len[p]+2;
}
oc[lst=t[p][c]]++;
}
} X;
int main() {
memset(S,1,sizeof S);
c=getchar();
while(c!='\n') X.add(c-'a'),c=getchar();
for(int x=X.sz;~x;x--)
X.oc[X.li[x]]+=X.oc[x];
for(int x=X.sz;~x;x--)
ans=max(ans,X.len[x]*X.oc[x]);
cout<<ans<<'\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |