#28014: CPP


11030067@mail.hpsh.tp.edu.tw (和平110級鄧雨珊)

學校 : 臺北市立和平高級中學
編號 : 163096
來源 : [61.64.210.174]
最後登入時間 :
2022-10-23 16:54:59
e786. b1.修辭迴文(Palindrome) -- 2019年12月TOI練習賽 | From: [219.85.43.159] | 發表日期 : 2021-11-10 01:03

#include <iostream>
using namespace std;

int main(){
string s;
while (getline(cin, s)){
int len=s.size();
if (len%2==1){
cout <<"NO\n";
continue;
}
bool p=true;
string ans;
for (int i=0; i<len/2; i++){
if (s[i]!=s[len-i-1]){
p=false;
break;
}
ans+=s[i];
}
if (p){
cout <<"YES\n"<< ans <<endl;;
}
else {
cout <<"NO"<<endl;
}
}
}
 
ZeroJudge Forum