Given a string, you are supposed to output the length of the longest symmetric sub-string. For example, given Is PAT&TAP symmetric?, the longest symmetric sub-string is s PAT&TAP s, hence you must output 11.
Input Specification:
Each input file contains one test case which gives a non-empty string of length no more than 1000.
Output Specification:
For each test case, simply print the maximum length in a line.
Sample Input:
Is PAT&TAP symmetric?
Sample Output:
11
#include <iostream>
#include <vector>
#include<algorithm>
#include <cmath>
#include<map>
#include<cstring>
#include<queue>
#include<string>
#include<set>
using namespace std;
typedef long long ll;
const int maxn=100010,inf=100000000;
string s;int ans=-1;
void lss(int left,int right){
int cnt=0;
while(left<s.length()&&right>=0&&s[left]==s[right]){
left--;right++;
}
ans=max(right-left-1,ans);
}
int main(){
getline(cin,s);
for(int i=0;i<s.length();i++){
lss(i,i+1);
lss(i,i);
}
if(ans==-1) cout<<"0";
else
cout<<ans;
}