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
26
27
28
29
#include <iostream>

using namespace std;

int main()
{
    std::ios::sync_with_stdio(false);
    unsigned int n,t;
    cin >> n;
    cin >> t;
    int tabL=1<<n;
    unsigned int* talia=new unsigned int[tabL];
    for(int i=0;i<tabL;i++){
        cin >> *(talia+i);
    }
    if (t&1) {
        cout << *(talia+tabL-1);
        for(int i=tabL-2;i>=0;--i){
            cout << ' ' << *(talia+i);
        }
    }else{
        cout << *(talia);
        for(int i=1;i<tabL;i++){
            cout << ' ' << *(talia+i);
        }
    }
    cout << endl;
    return 0;
}