1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
#include <vector>

int main() {
    int n;
    long t;
    std::vector<long> v;
    std::cin >> n >> t;

    unsigned int size = 1;
    for(int i = 0; i < n; i++) size *= 2;
    v.resize(size);
    for(int i = 0; i < size; i++) std::cin >> v[i];

    if(t%2 != 0)
        for(int i = size - 1; i >= 0; i--) std::cout << v[i] << " ";
    else
        for(int i = 0; i < size; i++) std::cout << v[i] << " ";
    return 0;
}