求救!

B4039 [GESP202409 三级] 回文拼接

piyuhan666 @ 2024-11-30 21:44:08

#include<bits/stdc++.h>
using namespace std;
int n;
bool f(string s){
    int a=0;
    int j=a,sum=0;
    for(int i=0;i<s.size();i++){
        if(s[i]!=s.size()-i-1){
            return 0;
        }
    }
    return 1;
}
int main(){
    cin>>n;
    bool v=0;
    for(int i=1;i<=n;i++){
        string s;
        cin>>s;
        for(int j=2;j<=s.size();j++){
            string a = s.substr(0, j);
            string b = s.substr(j);
            if(f(a)&&f(b)){
                v=1;
                break;
            }
        }
        if(v==1){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }   
    return 0;
}

by LionBlaze @ 2024-11-30 21:49:47

@piyuhan666 if(s[i]!=s.size()-i-1){ 是什么梗


by piyuhan666 @ 2024-11-30 21:52:48

@LionBlaze 这个,额(搔头中),烦请壶关


by piyuhan666 @ 2024-11-30 21:54:07

@LionBlaze 还是错的,呜呜呜


by LionBlaze @ 2024-12-01 09:58:19

@piyuhan666 互你*啊


by LionBlaze @ 2024-12-01 11:47:16

@piyuhan666 for(int j=2;j<=s.size();j++){ -> for(int j=2;j+2<=s.size();j++){


|