1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <cstdio>

int a[(1 << 20) + 1];
int n, t;

int main() {
    scanf("%d%d", &n, &t);
    int xoxo = (1 << n) - 1;
    for (int i = 0; i < 1 << n; i++) {
        int k;
        scanf("%d", &k);
        if (t % 2) {
            a[i ^ xoxo] = k;
        } else {
            a[i] = k;
        }
    }
    for (int i = 0; i < 1 << n; i++) {
        printf("%d ", a[i]);
    }
    printf("\n");
    return 0;
}