Advertisement
jeff69

Untitled

May 1st, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. #include<iostream>
  2. #include<queue>
  3. #include<vector>
  4. #include<set>
  5. #include<cmath>
  6. #include <map>
  7. #include<math.h>
  8. #include<cstring>
  9. #include<string>
  10. typedef long double ld;
  11.  
  12. typedef long long ll;
  13. using namespace std;
  14.  
  15. vector<string> V;
  16. string a;
  17. map <string, int > pie;
  18. void calc( int x){
  19. if (x>=a.length())return;
  20. string cas;
  21. if (a.length() - x >= 2){
  22. //cout << cas << '\n';
  23. cas = a.substr(x, 3);
  24. reverse(cas.begin(), cas.end());
  25. if (pie[cas] != 0)
  26. {
  27. return;
  28. }
  29. if (cas.length()>1&&pie[cas]==0)
  30. V.push_back(cas);
  31. ++pie[cas];
  32. calc(x + 3);
  33. --pie[cas];
  34.  
  35. }
  36. if (a.length() - x >= 1){
  37. cas = a.substr(x, 2);
  38. if (pie[cas] != 0)
  39. {
  40. return;
  41. }
  42. reverse(cas.begin(), cas.end());
  43. if (cas.length()>1 ) V.push_back(cas);
  44. ++pie[cas];
  45. calc(x + 2);
  46. --pie[cas];
  47. }
  48. else return;
  49. }
  50. int main(){
  51.  
  52. cin >> a;
  53. if (a.length() == 5){
  54. cout << 0;
  55. return 0;
  56. }
  57. a.erase(0, 5);
  58. reverse(a.begin(), a.end());
  59. //cout << a << '\n';
  60. calc(0);
  61.  
  62. sort(V.begin(), V.end());
  63. map<string,int> rep;
  64.  
  65.  
  66. vector<string > ans;
  67. for (int i = 0; i < V.size(); i++){
  68. if (rep[V[i]] == 0)ans.push_back(V[i]);
  69. ++rep[V[i]];
  70.  
  71. }
  72. cout << ans.size()<<'\n';
  73. for (int i = 0; i < ans.size(); ++i){
  74. cout << ans[i] << '\n';
  75. }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement