Advertisement
jeff69

Untitled

Mar 26th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. #include <iomanip>
  2. #include <iostream>
  3. #include <functional>
  4. #include <algorithm>
  5. #include <math.h>
  6. #include <cmath>
  7. #include <string>
  8. #include <vector>
  9. #include<set>
  10. #include<map>
  11. #include <time.h>
  12. #include <fstream>
  13. using namespace std;
  14. typedef long long ll;
  15.  
  16. typedef double d;
  17. typedef long long ll;
  18. string v;
  19. vector< string > z;
  20. int l;
  21. bool check(int t){
  22. string tst;
  23.  
  24. for (int l = 1; t + l + l - 1 < v.length();++l)
  25. if (v.substr(t, l) == v.substr(t+l, l))return false;
  26.  
  27. return true;
  28. }
  29.  
  30. bool valid(){
  31. int sigma = 0;
  32. for (int t = 0; t < v.length(); t++){
  33. if(check(t))sigma++;
  34.  
  35. if (2 * sigma < t+1)return false;
  36.  
  37.  
  38.  
  39.  
  40. }
  41. return true;
  42.  
  43.  
  44. }
  45. void solve(int x){
  46. if (!valid())return;
  47.  
  48.  
  49.  
  50. if (x == l){
  51. z.push_back(v);
  52. return;
  53.  
  54. }
  55. v.push_back('0');
  56. solve(x + 1);
  57. v.pop_back();
  58.  
  59. v.push_back('1');
  60. solve(x + 1);
  61. v.pop_back();
  62.  
  63. }
  64. int main()
  65. {freopen("free.in", "r", stdin);
  66.  
  67. freopen("free.out", "w", stdout);
  68. cin >> l;
  69.  
  70.  
  71. solve(0);
  72.  
  73. cout << z.size() << endl;
  74. for (int i = 0; i < z.size(); i++){
  75. cout << z[i] << endl;
  76. }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement