#include<bits/stdc++.h>
using namespace std;
map<string,int> a;
map<string,bool> b;
string c[5000000];
long long cpos=0;
long long d,maxd=INT_MIN;
bool palindrome(string str){
for(int i=0,j=str.length()-1;i<j;i++,j--){
if(str[i]!=str[j]){
return false;
}
}
return true;
}
void f(int step,string str){
for(int i=0;i<str.size()-step+1;i++){
if(palindrome(str.substr(i,step))){
if(!b[str.substr(i,step)]){
b[str.substr(i,step)]=true;
c[cpos]=str.substr(i,step);
cpos++;
}
a[str.substr(i,step)]++;
}
}
if(step<str.size()){
f(step+1,str);
}
}
int main(){
string s;
getline(cin,s);
f(1,s);
for(long long i=0;i<cpos;i++){
d=c[i].length()*a[c[i]];
if(d>maxd){
maxd=d;
}
}
cout<<maxd;
return 0;
}
本地样例过了
palindrome判断回文数
f函数找出回文子串
最后打擂台找最大的
大佬求调