#include #include #include using namespace std ; /* ifstream cin ("input") ; ofstream cout ("output") ;*/ void solve (int times, int n, vector &v) { if (times == n + 1) { for (auto x : v) { cout << x << '\n' ; } return ; } vector aux = v ; reverse (aux.begin(), aux.end()) ; for (auto &x : v) { x += "0" ; } for (auto &x : aux) { x += "1" ; } for (auto x : aux) { v.push_back (x) ; } solve (times + 1 , n , v) ; } int main(int argc, char const *argv[]) { int n ; cin >> n ; /*vector v ; for (int i = 0 ; i < (1 << n) ; ++ i) { v.push_back (i) ; } do { bool ok = true ; int last = v[0] ; for (int i = 1 ; i < (int)v.size() ; ++ i) { int cate = 0 ; for (int j = 0 ; j < n ; ++ j) { int bit1 = v[i] & (1 << j) ; int bit2 = last & (1 << j) ; if (bit1) bit1 = 1 ; if (bit2) bit2 = 1 ; if (bit1 != bit2) { ++ cate ; } if (cate > 1) break ; } last = v [i] ; if (cate > 1) { ok = false ; break ; } } if (ok == true) { for (auto x : v) { for (int j = 0; j < n ; ++ j) { if (x & (1 << j)) { cout << 1 ; } else { cout << 0 ; } } cout << '\n' ; } break ; } }while (next_permutation(v.begin(), v.end())) ;*/ vector v (1, "") ; solve (1, n, v) ; return 0; }