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
#include <cstdio>

int arr[1<<21];

int main() {
    int n,t;
    scanf("%d%d", &n, &t);
    int p2n = 1<<n;
    for (int i=0; i<p2n; i++) {
        scanf("%d", &arr[i]);
    }
    if (t%2 == 1) {
        int i=0;
        int j = p2n-1;
        while (i < j) {
            int c = arr[i];
            arr[i] = arr[j];
            arr[j] = c;
            i++; j--;
        }
    }
    for (int i=0; i < p2n; i++) {
        printf("%d ", arr[i]);
    }
    return 0;
}