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>

const int MAXN = 2 << 20;

int numbers[MAXN];
int k, n, t;

inline int printNumber(const int & num) {
	printf("%d ", num);
}

int main() {
	scanf("%d %d", &k, &t);
	n = 1 << k;
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &numbers[i]);
	}
	int start, end, step;
	if (t % 2 == 0) {
		for (int i = 1; i <= n; ++i) {
			printNumber(numbers[i]);
		}
	} else {
		for (int i = n; i > 0; i--) {
			printNumber(numbers[i]);
		}
	}
}