fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define int long long
  4. #define str string
  5.  
  6. int t;
  7. str s;
  8.  
  9. int check(){
  10. cin >> s;
  11. int dem = 0;
  12. for (int i = 0; i < s.size() / 2; i ++){
  13. if (s[i] != s[s.size() - i - 1]) dem ++;
  14. if (dem > 2){
  15. cout << "NO" << endl;
  16. return 0;
  17. }
  18. }
  19. cout << "YES" << endl;
  20.  
  21. return 0;
  22. }
  23.  
  24. signed main(){
  25. freopen ("REPLACE.INP", "r", stdin);
  26. freopen ("REPLACE.OUT", "w", stdout);
  27.  
  28. cin >> t;
  29.  
  30. while (t --){
  31. check();
  32. }
  33. }
Success #stdin #stdout 0s 5300KB
stdin
Standard input is empty
stdout
Standard output is empty