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

int main() {
        int n,t, *a,n2,i,b;
        scanf("%d %d\n", &n, &t);
        n2 = 1 << n;
        if (t%2) {
                a = malloc(n2*sizeof(*a));
                for (i=0; i<n2; ++i)
                        scanf("%d", a+i);
                printf("%d", a[--n2]);
                while (n2--)
                        printf(" %d", a[n2]);
        } else {
                scanf("%d", &b);
                printf("%d", b);
                --n2;
                while (n2--) {
                        scanf("%d", &b);
                        printf(" %d", b);
                }
        }
        printf("\n");
        return 0;

}