fork(3) download
  1. # include <bits/stdc++.h>
  2. using namespace std;
  3. int main(void)
  4. {
  5. string s;
  6. cin>>s;
  7. s = '#' + s;
  8. int n = s.length() - 1;
  9. int cnt = 0;
  10. for (int i = 1;i + i <= n;++i)
  11. if (s[i] != s[n - i + 1])
  12. ++cnt;
  13. if ((cnt <= 1 && (n&1)) || cnt == 1) puts("YES");
  14. else puts("NO");
  15. return 0;
  16. }
  17.  
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
NO