借鉴
查看原帖
借鉴
917179
ly18976209180楼主2025/8/5 12:48

可借鉴,别举报。

#include<bits/stdc++.h>
using namespace std;
bool is(const string &s, int start, int end) 
{
    while (start < end) 
	{
        if (s[start] != s[end]) 
		{
            return false;
        }
        start++;
        end--;
    }
    return true;
}
bool c(const string &s) 
{
    int n = s.length();
    for(int i=2;i<=n-2;++i) 
	{
        if(is(s,0,i-1)&&is(s,i,n-1)) 
		{
            return true;
        }
    }
    return false;
}

int main() 
{
    int n;
    cin >> n;
    for (int i = 0; i < n;++i) 
	{
        string s;
        cin >> s;
        if (c(s)) 
		{
            cout << "Yes" << endl;
        } else 
		{
            cout << "No" << endl;
        }
    }
    return 0;
}
2025/8/5 12:48
加载中...