#include<bits/stdc++.h>
#define N 300100
using namespace std;
long long S[N],ans,c;
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[sz]=c;
while (S[sz-1-len[p]]-c)p=li[p];
if (!t[p][c]) {
int q=li[p];
while(S[sz-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 |
1 |
Correct |
2 ms |
9048 KB |
Output is correct |
2 |
Correct |
2 ms |
9052 KB |
Output is correct |
3 |
Incorrect |
1 ms |
9052 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
9048 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
9048 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
9052 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
9052 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |