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
30
31
32
33
34
#include <iostream>
#include <vector>

unsigned int pow(int n) {
    unsigned int res = 1;
    for(int i=0; i<n; i++) {
        res *= 2;
    }
    return res;
}

int main() {
    std::ios_base::sync_with_stdio(0);

    int _n, _t;
    std::cin >> _n >> _t;
    const int n(_n);
    const int t(_t);

    const unsigned int n_pow = pow(n);

    std::vector<int> data(n_pow);
    for(unsigned int i=0; i<n_pow; i++) {
        std::cin >> data[i];
    }

    unsigned int counter;
    for(unsigned int i=0; i<n_pow; i++) {
        counter = t % 2 == 0 ? i : n_pow - i - 1;
        std::cout << data[counter] << " ";
    }

    return 0;
}