全RE!

B4039 [GESP202409 三级] 回文拼接

a89888988 @ 2024-12-04 19:28:03

#include <bits/stdc++.h>
using namespace std;

int main() {
    string s = "", s1 = "", s2 = "", s3 = "", s4 = "";
    int T;
    bool flag = 0;
    cin >> T;
    for (int i = 0; i < T; i++) {
        s="";
        flag=0;
        cin >> s;
        for (int j = 2; j <= s.size() - 2; j++) {
            s1 = "", s2 = "", s3 = "", s4 = "";
            s1 = s.substr(0, j);
            s2 = s.substr(j);
            s3 = s1;
            s4 = s2;
            reverse(s1.begin(), s1.end());
            reverse(s2.begin(), s2.end());
            if (s1 == s3 && s2 == s4) {
                flag = 1;
                break;
            }
        }
        if (flag == 1) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}

by lsrlsrlsr @ 2024-12-15 11:18:20

见此页


by lsrlsrlsr @ 2024-12-15 11:18:53

求关@a89888988


|