fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int isPalindrome(string str)
  7. {
  8. int l = 0;
  9. int h = str.size() - 1;
  10.  
  11. while (h > l)
  12. {
  13. if (str[l++] != str[h--])
  14. {
  15. return 0;
  16. }
  17. }
  18. return 1;
  19. }
  20. int main()
  21. {
  22. int test;
  23. cin >> test;
  24.  
  25. while(test--)
  26. {
  27. string s;
  28. cin >> s;
  29.  
  30. if(isPalindrome(s))
  31. {
  32. cout << "YES";
  33. if(s.size()%2==0)
  34. {
  35. cout << " EVEN" << endl;
  36. }
  37. else
  38. {
  39. cout << " ODD" << endl;
  40. }
  41. }
  42. else
  43. {
  44. cout << "NO" << endl;
  45. }
  46. }
  47.  
  48. return 0;
  49. }
Success #stdin #stdout 0s 3476KB
stdin
3
abc
abba
aba
stdout
NO
YES EVEN
YES ODD