제출 #556062

#제출 시각아이디문제언어결과실행 시간메모리
556062MurotYPalindromes (APIO14_palindrome)C++14
8 / 100
1085 ms131072 KiB
// 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++){
		ll pos=i, len=0;
		string a="";
		for (int j=i-1;j>=0;j--){
			if (pos >= n) break;
			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];
		ans=max(ans, len*mp[a]);
		for (int j=i-1;j>=0;j--){
			if (pos >= n) break;
			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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...