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>
#include <algorithm>
using namespace std;

const int maxn = 2000000;

int a[maxn];

int main() {

    int n, t;

    scanf("%d%d", &n, &t);

    for(int i = 0; i < (1 << n); ++i)
        scanf("%d", a + i);

    if(t & 1)
        reverse(a, a + (1 << n));

    for(int i = 0; i < (1 << n); ++i)
        printf("%d ", a[i]);
}