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

using namespace std;

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

int main()
{
    scanf("%d%d", &n, &t);
    int N = 1 << n;
    for (int i=0; i<N; ++i)
        scanf("%d", &buf[i]);
    if (t & 1)
    {
        printf("%d", buf[N-1]);
        for (int i = N-2; i >= 0; --i)
            printf(" %d", buf[i]);
    }
    else
    {
        printf("%d", buf[0]);
        for (int i = 1; i < N; ++i)
            printf(" %d", buf[i]);
    }
    putchar('\n');
    return 0;
}