参考:https://blog.csdn.net/CSDN_FengXingwei/article/details/82429808
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int getMaxPlalindrome(string s)
{
int len = s.size();
int start, end;
vector<vector<bool>> dp;
vector<bool> temp;
for (int i = 0; i < len; i++)
{
temp.clear();
for (int j = 0; j < len; j++)
{
temp.push_back(false);
}
dp.push_back(temp);
}
for (int i = 0; i < len; i++)
{
for (int j = 0; j < len - i; j++)
{
if (i == 0)
{
dp[j][j + i] = true;
}
else if (i == 1)
{
dp[j][j + i] = true;
}
else
{
if (dp[j + 1][j + i - 1] && (s[j] == s[j + i]))
dp[j][j + i] = true;
}
if (dp[j][j + i] == true)
{
start = j;
end = j + i;
}
}
}
return end - start + 1;
}
int main()
{
string s;
while (cin >> s)
{
cout << getMaxPlalindrome(s) << endl;
}
}