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
#include <stdio.h>

int a[1048576];

int main(void) {
	int n, t, ptr = 1;
	scanf("%d %d", &n, &t);
	t %= 2;
	for (int i = 1; i <= n; i++) {
		ptr *= 2;
	}
	for (int i = 0; i < ptr; i++) {
		scanf("%d", &a[i]);
	}
	if (t) {
		for (int i = ptr-1; i >= 0; i--) {
			printf("%d ", a[i]);
		}
 	} else {
 		for (int i = 0; i < ptr; i++) {
 			printf("%d ", a[i]);
 		}
 	}
 	
	return 0;
}