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>
using namespace std;
const long long maxn=1e4+10;
const long long mod=1e9+7;
int main()
{
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
string s;
long long ans=0LL;
cin>>s;
int n=s.size();
map<deque<char>,int>m;
for(int i=0;i<n;i++)
{
deque<char>Q;
int l=i;
int r=i;
Q.push_front(s[i]);
m[Q]++;
while(l-1>=0 && r+1<n)
{
if(s[l-1]==s[r+1])
{
l--;
r++;
Q.push_front(s[l]);
Q.push_back(s[r]);
m[Q]++;
}
else
{
break;
}
}
}
for(auto ax:m)
{
long long num=ax.first.size()*ax.second;
ans=max(num,ans);
}
m.clear();
for(int i=0;i<n-1;i++)
{
deque<char>Q;
int l=i;
int r=i+1;
if(s[l]!=s[r])continue;
Q.push_front(s[l]);
Q.push_back(s[r]);
m[Q]++;
while(l-1>=0 && r+1<n)
{
if(s[l-1]==s[r+1])
{
l--;
r++;
Q.push_front(s[l]);
Q.push_back(s[r]);
m[Q]++;
}
else
{
break;
}
}
}
for(auto ax:m)
{
long long num=ax.first.size()*ax.second;
ans=max(num,ans);
}
cout<<ans<<endl;
return 0;
}
# | 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... |