https://ac.nowcoder.com/acm/problem/214851
#include <iostream>
#include <string>
using namespace std;
string s;
int n;
int fun()
{
// 1. 判断是否全都是相同字符
bool flag = false;
for (int i = 1; i < n; ++i)
{
if (s[i] != s[0])
{
flag = true;
break;
}
}
if (flag == false) return 0;
// 2. 判断本身是否是回文
flag = true;
int left = 0, right = n-1;
while (left < right)
{
if (s[left] == s[right])
{
left++;
right--;
}
else
{
flag = false;
break;
}
}
if (flag) return n-1;
else return n;
}
int main()
{
cin >> s;
n = s.size();
cout << fun() << endl;
return 0;
}