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

int main() {
	int N,T;
	std::vector<int> values;

	scanf("%d %d", &N,&T);
	for (int i=0; i<(1<<N); ++i) {
		int x;
		scanf("%d",&x);
		values.push_back(x);
	}

	if (T%2 == 1) {
		std::reverse(values.begin(), values.end());
	}

	for (int i=0; i<(1<<N); ++i) {
		printf("%d ", values[i]);
	}

	return 0;
}