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


int main()
{
    std::ios_base::sync_with_stdio(false);
    int n, t;
    int pow2[21] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096,
                   8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576};
    int* tab;
    std::cin >> n >> t;
    tab = new int[pow2[n]];
    for (int i = 0; i < pow2[n]; ++i)
        std::cin >> tab[i];
    if (t & 1)
        for (int i = pow2[n] - 1; i >= 0; --i)
            std::cout << tab[i] << " ";
    else
        for (int i = 0; i < pow2[n]; ++i)
            std::cout << tab[i] << " ";
    std::cout << std::endl;
    delete [] tab;
    return 0;
}