P
Size: a a a
P
P
P
УМ
УМ
#include <iostream>
#include <string>
using namespace std;
bool check(string a)
{
int c = 0;
int c2 = 0;
for (int i = 1; i < a.size(); i++)
{
if (a[0] != a[i])
c++;
}
for (int i = a.size() - 2; i >= 0; i--)
{
if (a[a.size() - 1] != a[i])
c2++;
}
if (c2 == 1 || c == 1)
return true;
else
return false;
}
string cut(string a,int c,int d)
{
string res;
for (int i = c; i <= d; i++)
{
res += a[i];
}
return res;
}
int main()
{
string text;
cin >> text;
int c = 0;
//caaccccaed
for (int i = 0; i < text.size()-2; i++)
{
string compW;
for (int j = i+2; j < text.size(); j++)
{
compW = cut(text,i, j);
if (check(compW))
c++;
else
j = text.size();
}
}
cout << c << endl;
}
УМ
УМ
УМ
УМ
Мв
Мв
P