GESP202409 三级 回文拼接题解
2026-02-10 13:36:31
发布于:四川
12阅读
0回复
0点赞
A46107.[GESP202409 三级] 回文拼接
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+10;
char a[N];
bool check(int L,int R){//判断回文函数
while(L<R){
if(a[L]==a[R]);
else return 0;
L++,R--;
}
return 1;
}
int func(){//判断回文拼接函数
int len=strlen(a);
for(int i=1;i<=len-3;i++){
if(check(0,i) && check(i+1,len-1)){
return 1;
}
}
return 0;
}
int main(){
int t;
cin >> t;
for(int i=1;i<=t;i++){//调用函数
cin >> a;//输入字符数组
if(func()) cout << "Yes\n";//函数判断
else cout << "No\n";
}
return 0;
}
这里空空如也






有帮助,赞一个