fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. #define pi 3.14159265359
  5. #define el <<"\n"
  6.  
  7. int main() {
  8. ios::sync_with_stdio(false);
  9. cin.tie(nullptr);
  10. cout.tie(nullptr);
  11.  
  12. char s[10000];
  13. cin>>s;
  14. int len = 0;
  15. while(s[len] != '\0'){
  16. len++;
  17. }
  18. bool palindrome = true;
  19. for(int i = 0;i<len/2;i++){
  20. if(s[i] != s[len - 1 - i]){
  21. palindrome = false;
  22. break;
  23. }
  24. }
  25.  
  26. if(palindrome){
  27. cout<< "YES" el;
  28. }
  29. else{
  30. cout<< "NO" el;
  31. }
  32. return 0;
  33. }
Success #stdin #stdout 0.01s 5320KB
stdin
abba
stdout
YES