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
#include <stdio.h>
#include <cmath>




int main() {

    int n, t;
    scanf("%i %i", &n, &t);
    //printf("%i %i\n", n, t);

    int size = (int)(pow(2,n));
    //printf("%i\n", size);
    int a[size];
    for (int i=0; i<size; ++i) {
        scanf("%i", &a[i]);
    }
    //for (int i=0; i<size; ++i) printf("a[%i]=%i\n",i,a[i]);

    if (t%2==0) {
        for (int i=0; i<size-1; ++i) printf("%i ", a[i]);
        printf("%i\n", a[size-1]);
    } else {
        for (int i=size-1; i>0; --i) printf("%i ", a[i]);;
        printf("%i\n", a[0]);
    }

    return 0;
}