1 条题解

  • 0
    @ 2025-11-29 15:28:46
    #include <bits/stdc++.h>
    using namespace std;
    
    bool chk2(string s){
        string s2=s;
        reverse(s2.begin(),s2.end());
        if(s==s2) return true;
        else return false;
    }
    
    bool chk(string s){
        string s1,s2;
        int len=s.length();
        for(int i=2;i<=len-2;i++){
            s1=s.substr(0,i);
            s2=s.substr(i,len-i);
            if(chk2(s1) && chk2(s2)) return true;
        }
        return false;
    }
    
    int main(){
        int n;
        string s;
        //
        cin >> n;
        while(n--){
            cin >> s;
            //
            if(chk(s)) cout << "Yes" << endl;
            else cout << "No" << endl;
        }
        return 0;
    }
    
    • 1

    回文拼接(洛谷 B4039 普及-)(字符串截取+回文字符串)(GESP3级真题)

    信息

    ID
    619
    时间
    1000ms
    内存
    256MiB
    难度
    8
    标签
    (无)
    递交数
    20
    已通过
    7
    上传者