题解:P14631 [2018 KAIST RUN Fall] Repetitive Palindrome
字符串 abca 反着读是 acba,但重复的最后一遍是 abca。
字符串
因此,如果
所以只需要判断
代码
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ft first
#define sd second
#define fs(i,x,y) for(int i=(x);i<=(y);i++)
#define fj(i,x,y) for(int i=(x);i>=(y);i--)
signed main(){
std::ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
string s;
cin>>s;
int l=s.length()-1;
for(int i=0,j=l;i<j;i++,j--){
if(s[i]!=s[j]){
cout<<"NO";
return 0;
}
}
cout<<"YES";
return 0;
}