Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iomanip>
- #include <iostream>
- #include <functional>
- #include <algorithm>
- #include <math.h>
- #include <cmath>
- #include <string>
- #include <vector>
- #include<set>
- #include<map>
- #include <time.h>
- #include <fstream>
- using namespace std;
- typedef long long ll;
- typedef double d;
- typedef long long ll;
- string v;
- vector< string > z;
- int l;
- bool check(int t){
- string tst;
- for (int l = 1; t + l + l - 1 < v.length();++l)
- if (v.substr(t, l) == v.substr(t+l, l))return false;
- return true;
- }
- bool valid(){
- int sigma = 0;
- for (int t = 0; t < v.length(); t++){
- if(check(t))sigma++;
- if (2 * sigma < t+1)return false;
- }
- return true;
- }
- void solve(int x){
- if (!valid())return;
- if (x == l){
- z.push_back(v);
- return;
- }
- v.push_back('0');
- solve(x + 1);
- v.pop_back();
- v.push_back('1');
- solve(x + 1);
- v.pop_back();
- }
- int main()
- {freopen("free.in", "r", stdin);
- freopen("free.out", "w", stdout);
- cin >> l;
- solve(0);
- cout << z.size() << endl;
- for (int i = 0; i < z.size(); i++){
- cout << z[i] << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement