This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// author : Murot_06
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define ios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ff first
#define ll long long
#define ss second
using namespace std;
const int N=1e6+7, M=1e9+7;
void solve()
{
string s;
cin >> s;
int n=s.size();
map <string, ll> mp;
for (int i=0;i<n;i++){
string a="";
for (int j=i;j<n;j++){
a=a+s[j];
mp[a]++;
}
}
ll ans=0;
for (int i=0;i<n;i++){
int pos=i, len=0;
string a="";
for (int j=i-1;j>=0;j--){
if (s[j] == s[pos] && pos < n) len+=2, a=s[j]+a+s[pos], pos++;
ans=max(ans, len*mp[a]);
}
pos=i+1, len=1;
a=s[i];
for (int j=i-1;j>=0;j--){
if (s[j] == s[pos] && pos < n) len+=2, a=s[j]+a+s[pos], pos++;
ans=max(ans, len*mp[a]);
}
ans=max(ans, len*mp[a]);
// if (i == 3) cout << a <<" ";
}
cout << ans;
return ;
}
int main()
{
ios;
int t=1;
// cin >> t;
while (t--){
solve();
}
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... |