劳驾大佬解决一下

B4039 [GESP202409 三级] 回文拼接

liuqinghao1 @ 2024-11-24 13:26:26

请帮我看看这宝了个贝的WA O.o

#include<iostream>
#include<algorithm>
using namespace std;

int a[7],temp,b[7],t;

int main()
{
    int temp;
    cin>>temp;
    string s;
    for(int k=0;k<temp;k++)
    {
        cin>>s;
        for (int i = 2; i + 1 < s.length(); i++) {
        string a = s.substr(0, i);
        string b = s.substr(i);
        bool flag = true;
        for (int j = 0; j < a.length(); j++) {
            if (a[j] != a[a.length() - j - 1])
                flag = false;
        }
        for (int j = 0; j < b.length(); j++) {
            if (b[j] != b[b.length() - j - 1])
                flag = false;
        }
        if (flag) cout << "No" << endl;
        else cout<<"Yes"<<endl;
        }
    }
    return 0;
}

谢谢大佬


by liuqinghao1 @ 2024-11-24 13:26:47

谢谢


|