1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
#include<iostream>
using namespace std;
main(){
 int n,t,N;
 int * D;
 cin >> n;
 cin >> t;
 N=2<<n-1;
 D = new int[N];
 for(int i=0;i<N;i++)cin >> D[i];
 if(t%2)
    for(int i=N-1;i>=0;i--) cout << D[i] << " ";
 else
    for(int i=0  ;i<N;i++)  cout << D[i] << " ";
 cout << endl;
 return 0;
}