1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
#include <cstdio>
#include <algorithm>

int main() {
    int n, t, tab[1<<20];
    scanf("%d%d", &n, &t);
    for(int i = 0; i < (1<<n); i++)
        scanf("%d", &tab[i]);
    if(t % 2 == 1)
        std::reverse(tab, tab + (1<<n));
    for(int i =0; i < (1<<n); i++)
        printf("%d ", tab[i]);
    printf("\n");
    return 0;
}