P14631 [2018 KAIST RUN Fall] Repetitive Palindrome
P14631 [2018 KAIST RUN Fall] Repetitive Palindrome
solution
注意到
仔细分析。
如果字符串
所以本题中的 YES;否则输出 NO。
AC code
#include <bits/stdc++.h>
#define debug(a) cerr << (#a) << " = " << (a) << endl;
#define int long long
#define maxn 100010
#define endl '\n'
using namespace std;
int k;
string s;
void solve() {
for (int i = 0; i < s.size() / 2; i++) {
if (s[i] != s[s.size() - i - 1]) {
cout << "NO" << endl;
exit(0);
}
}
cout << "YES" << endl;
}
signed main() {
cin >> s >> k;
solve();
return 0;
}
其它
码字不易,求赞喵!