1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
#include <cstdio>
int t[1<<20], n, m;
int main() {
	scanf("%d%d", &n, &m);
	n = 1 << n;
	for (int i = 0; i < n; i++) {
		scanf("%d", t+i);
	}
	if (m&1) {
		for (int i = n-1; i >= 0; i--) {
			printf("%d ", t[i]);
		}
	} else {
		for (int i = 0; i < n; i++) {
			printf("%d ", t[i]);
		}
	}
	printf("\n");
}