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

#define For(i, n) for(int i = 0; i < (n); i++)
#define ForD(i, n) for(int i = (n) - 1; i >= 0; i--)

using namespace std;

const int N = 1000 * 1000 + 10;
int A[N];

int main()
{
    int n, t;
    scanf("%d %d", &n, &t);

    For (i, 1 << n)
        scanf("%d", &A[i]);

    if (t & 1)
        ForD (i, 1 << n)
            printf("%d ", A[i]);
    else
        For (i, 1 << n)
            printf("%d ", A[i]);
}