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

int N, k;
vector<int> seq;

int main() {
	scanf("%d %d", &N, &k);
	N = (1<<N);
	for(int i = 0; i< N; i++) {
		int x;
		scanf("%d", &x);
		seq.push_back(x);
	}
	if(k%2)
		reverse(seq.begin(), seq.end());
	for(auto k: seq) {
		printf("%d ", k);
	}
	printf("\n");
	return 0;
}