#include #include #include #include #include void set(std::vector*m,std::vector *f,int l,int r) { if(r == l){ f->push_back(m->at(r)); return; } int mid = (r+l)/2; f->push_back(m->at(mid)); set(m,f,l,mid-1); set(m,f,mid+1,r); } int main() { int N,s,m; std::vector v,f; std::cin >> N; srand((unsigned)time(NULL)); s = pow(2,N)-1; for(int i = 0;i < s;i++) v.push_back(i+1); for(int i = 0;i < s;i++){ m = rand()%(s-i); f.push_back(v.at(m)); v.erase(v.begin()+m); } set(&f,&v,0,s-1); for(int i = 0;i < s;i++) std::cout << v.at(i) << ' '; std::cout << std::endl; return 0; }