#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 |
1 |
Correct |
1 ms |
9052 KB |
Output is correct |
2 |
Correct |
1 ms |
9052 KB |
Output is correct |
3 |
Correct |
1 ms |
9052 KB |
Output is correct |
4 |
Correct |
1 ms |
9144 KB |
Output is correct |
5 |
Correct |
1 ms |
9052 KB |
Output is correct |
6 |
Correct |
1 ms |
9052 KB |
Output is correct |
7 |
Correct |
1 ms |
9052 KB |
Output is correct |
8 |
Correct |
1 ms |
9052 KB |
Output is correct |
9 |
Correct |
1 ms |
9052 KB |
Output is correct |
10 |
Correct |
1 ms |
9052 KB |
Output is correct |
11 |
Correct |
1 ms |
9052 KB |
Output is correct |
12 |
Correct |
1 ms |
9052 KB |
Output is correct |
13 |
Correct |
2 ms |
9052 KB |
Output is correct |
14 |
Correct |
1 ms |
9148 KB |
Output is correct |
15 |
Correct |
1 ms |
9052 KB |
Output is correct |
16 |
Correct |
1 ms |
9052 KB |
Output is correct |
17 |
Correct |
1 ms |
9052 KB |
Output is correct |
18 |
Correct |
2 ms |
9052 KB |
Output is correct |
19 |
Correct |
1 ms |
9052 KB |
Output is correct |
20 |
Correct |
1 ms |
9052 KB |
Output is correct |
21 |
Correct |
1 ms |
9052 KB |
Output is correct |
22 |
Correct |
1 ms |
9052 KB |
Output is correct |
23 |
Correct |
1 ms |
9052 KB |
Output is correct |
24 |
Correct |
1 ms |
9052 KB |
Output is correct |
25 |
Correct |
2 ms |
9052 KB |
Output is correct |
26 |
Correct |
2 ms |
9052 KB |
Output is correct |
27 |
Correct |
1 ms |
9052 KB |
Output is correct |
28 |
Correct |
2 ms |
9052 KB |
Output is correct |
29 |
Correct |
1 ms |
9052 KB |
Output is correct |
30 |
Correct |
2 ms |
9048 KB |
Output is correct |
31 |
Correct |
1 ms |
9052 KB |
Output is correct |
32 |
Correct |
1 ms |
9052 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
9308 KB |
Output is correct |
2 |
Correct |
1 ms |
9308 KB |
Output is correct |
3 |
Correct |
1 ms |
9308 KB |
Output is correct |
4 |
Correct |
1 ms |
9308 KB |
Output is correct |
5 |
Correct |
2 ms |
9308 KB |
Output is correct |
6 |
Correct |
2 ms |
9308 KB |
Output is correct |
7 |
Correct |
1 ms |
9308 KB |
Output is correct |
8 |
Correct |
1 ms |
9308 KB |
Output is correct |
9 |
Correct |
1 ms |
9308 KB |
Output is correct |
10 |
Correct |
1 ms |
9052 KB |
Output is correct |
11 |
Correct |
1 ms |
9052 KB |
Output is correct |
12 |
Correct |
1 ms |
9308 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
13144 KB |
Output is correct |
2 |
Correct |
2 ms |
13148 KB |
Output is correct |
3 |
Correct |
2 ms |
13020 KB |
Output is correct |
4 |
Correct |
2 ms |
13260 KB |
Output is correct |
5 |
Correct |
2 ms |
13148 KB |
Output is correct |
6 |
Correct |
2 ms |
13148 KB |
Output is correct |
7 |
Correct |
3 ms |
13148 KB |
Output is correct |
8 |
Correct |
2 ms |
9052 KB |
Output is correct |
9 |
Correct |
2 ms |
9148 KB |
Output is correct |
10 |
Correct |
3 ms |
10516 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
31324 KB |
Output is correct |
2 |
Correct |
10 ms |
31456 KB |
Output is correct |
3 |
Correct |
11 ms |
31580 KB |
Output is correct |
4 |
Correct |
10 ms |
31580 KB |
Output is correct |
5 |
Correct |
12 ms |
31528 KB |
Output is correct |
6 |
Correct |
9 ms |
25944 KB |
Output is correct |
7 |
Correct |
10 ms |
28416 KB |
Output is correct |
8 |
Correct |
3 ms |
9308 KB |
Output is correct |
9 |
Correct |
5 ms |
15964 KB |
Output is correct |
10 |
Correct |
9 ms |
28528 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
70748 KB |
Output is correct |
2 |
Correct |
26 ms |
70668 KB |
Output is correct |
3 |
Correct |
26 ms |
71076 KB |
Output is correct |
4 |
Correct |
26 ms |
71036 KB |
Output is correct |
5 |
Correct |
37 ms |
70996 KB |
Output is correct |
6 |
Correct |
25 ms |
65624 KB |
Output is correct |
7 |
Correct |
25 ms |
62044 KB |
Output is correct |
8 |
Correct |
5 ms |
9564 KB |
Output is correct |
9 |
Correct |
5 ms |
9564 KB |
Output is correct |
10 |
Correct |
29 ms |
61460 KB |
Output is correct |
11 |
Correct |
26 ms |
70956 KB |
Output is correct |
12 |
Correct |
7 ms |
17244 KB |
Output is correct |