#include <iostream>
#include <cstdio>
#include <string.h>
#include <algorithm>
using namespace std;
int main(void){
char str[1005];
gets(str);
int len = strlen(str);
int ans = 1;
for(int i = 0; i < len; i++){
int L = i - 1,R = i + 1;
int h = 1;
while(L >= 0 && R <= len - 1){
if(str[L] == str[R]){
L--;
R++;
h += 2;
}
else{
break;
}
ans = max(ans,h);
}
}
int h;
for(int i = 1; i < len; i++){
if(str[i] == str[i - 1]){
int h = 2;
int L = i - 2,R = i + 1;
while(L >= 0 && R <= len - 1){
if(str[L] == str[R]){
L--;
R++;
h += 2;
}
else{
break;
}
ans = max(ans,h);
}
}
}
cout<<ans<<endl;
return 0;
}
L2-008. 最长对称子串
最新推荐文章于 2025-04-16 22:28:19 发布