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 <cstdio>
using namespace std;

int main()
{
    int n, t;
    scanf("%d %d", &n, &t);
    int n2 = 1 << n;
    int tab[n2];
    for (int i = 0; i < n2; ++i)
        scanf("%d", &tab[i]);
    int begin = 0, step = 1, end = n2;
    if (t % 2 == 1) {
        begin = n2 - 1;
        step = -1;
        end = -1;
    }
    while (begin != end) {
        printf("%d ", tab[begin]);
        begin += step;
    }
    printf("\n");
    return 0;
}