fork(2) download
  1. // iostream is too mainstream
  2. #include <cstdio>
  3. // bitch please
  4. #include <iostream>
  5. #include <algorithm>
  6. #include <cstdlib>
  7. #include <vector>
  8. #include <set>
  9. #include <map>
  10. #include <queue>
  11. #include <stack>
  12. #include <list>
  13. #include <cmath>
  14. #include <iomanip>
  15. #define dibs reserve
  16. #define OVER9000 1234567890
  17. #define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
  18. #define tisic 47
  19. #define soclose 1e-8
  20. #define chocolate win
  21. // so much chocolate
  22. #define patkan 9
  23. #define ff first
  24. #define ss second
  25. #define abs(x) ((x < 0)?-(x):x)
  26. #define uint unsigned int
  27. #define dbl long double
  28. using namespace std;
  29. // mylittledoge
  30.  
  31. int main() {
  32. cin.sync_with_stdio(0);
  33. cin.tie(0);
  34. string s;
  35. cin >> s;
  36. int N =s.length();
  37. set<int> S;
  38. for(int i =0; i < N; i++) if(s[i] != s[N-1-i] && i < N-1-i) S.insert(i);
  39. if(S.empty()) {cout << "1\n" << s << "\n"; return 0;}
  40. if(S.size() > 2) {cout << "0\n"; return 0;}
  41. set<string> S2;
  42. ALL_THE(S,it) S.insert(N-1-(*it));
  43. if(N%2 != 0) S.insert(N/2);
  44. ALL_THE(S,it) ALL_THE(S,jt) {
  45. string s2 =s;
  46. swap(s2[*it],s2[*jt]);
  47. bool b =true;
  48. for(int i =0; i < N; i++) if(s2[i] != s2[N-1-i]) b =false;
  49. if(!b) continue;
  50. S2.insert(s2);}
  51. cout << S2.size() << "\n";
  52. ALL_THE(S2,it) cout << (*it) << "\n";
  53. return 0;}
  54.  
  55. // look at my code
  56. // my code is amazing
  57.  
Success #stdin #stdout 0s 3436KB
stdin
Standard input is empty
stdout
1