社区讨论
0分TLE
B4039[GESP202409 三级] 回文拼接参与者 1已保存回复 0
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 0 条
- 当前快照
- 1 份
- 快照标识符
- @mjpr5pob
- 此快照首次捕获于
- 2025/12/28 21:15 2 个月前
- 此快照最后确认于
- 2026/01/01 11:20 2 个月前
CPP
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
int n;
cin>>n;
for(int i=1;i<=n;i++){
string s,ta="",tb="";
cin>>s;
if(s.size()%2==0){
for(int j=0;j<s.size()/2;j++){
ta.push_back(s[j]);
}
tb=ta;
reverse(tb.begin(),tb.end());
if(ta==tb){
cout<<"Yes";
}
else cout<<"No";
}
else{
for(int j=0;j<(s.size()-1)/2;j++){
ta.push_back(s[j]);
}
tb=ta;
reverse(tb.begin(),tb.end());
if(ta==tb){
cout<<"Yes";
}
else cout<<"No";
}
cout<<endl;
}
return 0;
}
回复
共 0 条回复,欢迎继续交流。
正在加载回复...