1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include<iostream>
using namespace std;

int main(){
    int a[1048576];
    int n, t, i2;
    cin >> n >> t;
    int N = 1 << n;
    for (int i=0;i<N;i++){
        cin >> a[i];
    }
    if (t % 2 == 0){
        for (int i=0;i<N-1;i++){
            cout << a[i] << " ";
        }
        cout << a[N -1];
    } else {
        for (int i=0;i<N-1;i++){
            cout << a[N - 1 - i] << " ";
        }
        cout << a[0];
    }
    cout << endl;
    return 0;
}