#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
int A[600005];
string s,imsi;
int ssiz,dap,isiz;
map<string,pii> mp;
void manachers(string S,int N)
{
int r = 0, p = 0;
for(int i=0;i<N;i++)
{
if(i<=r) A[i]=min(A[2*p-1],r-i);
else A[i]=0;
while(i-A[i]-1>=0&&i+A[i]+1<N&&S[i-A[i]-1]==S[i+A[i]+1]) A[i]++;
if(i+A[i]>r)
{
r=i+A[i];
p=i;
}
}
}
int main(void)
{
cin >> imsi;
isiz = imsi.size();
s+='#';
for(int i=0;i<isiz;i++)
{
s+=imsi[i];
s+='#';
}
ssiz = s.size();
manachers(s,ssiz);
for(int i=1;i<ssiz;i+=2)
{
string now;
for(int j=i-A[i]+1;j<=i+A[i]-1;j+=2) now+=s[j];
int nsiz = now.size();
for(int j=nsiz;j>0;j-=2)
{
//printf("%s\n",now.c_str());
mp[now].second=now.size();
mp[now].first++;
string newnow;
for(int i=1;i<nsiz-1;i++)
{
newnow=now[i];
}
now=newnow;
}
}
map<string,pii>::iterator iter;
for(iter=mp.begin();iter!=mp.end();iter++)
{
int score = (*iter).second.first*(*iter).second.second;
dap = max(dap,score);
}
printf("%d",dap);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Incorrect |
2 ms |
356 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
324 ms |
1080 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1085 ms |
1892 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1066 ms |
1892 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1077 ms |
2468 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |