#include #include using namespace std; int main(){ int K; cin >> K; int n_node = pow(2, K) - 1; int a[n_node]; // initialize for(int i=0; i< n_node; i++) a[i] = 0; int center = pow(2, K) / 2; a[0] = center; int left = center/ 2; int j=0; // Generate sequence of number which generates Complete Binary Tree. while(left >= 1){ j++; a[j] = left; int d = center; // common difference while(a[j] + d <= n_node){ a[j+1] = a[j] + d; j++; } center = left; left /= 2; } int i3=0,i2=0; bool t3=false, t2=false; // find where are 3 and 2 then swap them while(!t3 || !t2){ if(a[i2] == 2) t2=true; if(a[i3] == 3) t3=true; if(!t2) i2++; if(!t3) i3++; } a[i2] = 3; a[i3] = 2; for(int i=0; i