1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int n, t;
vector<int> V;

int main()
{
    scanf("%d %d", &n, &t); V.resize(1 << n);
    for (int i=0; i<V.size(); ++i) scanf("%d", &V[i]);
    if (t%2 == 1) reverse(V.begin(), V.end());
    for (int i=0; i<V.size(); ++i) printf("%d ", V[i]);
    printf("\n");
}