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
#include <cstdio>
#include <cstdlib>

int main() {
	int n, i, t, length;
	scanf("%d %d", &n, &t);
	length = 1 << n;
	if (t & 1) {
		int* cards = (int*)malloc(length * sizeof(int));
		for (i = 0; i < length; ++i) {
			scanf("%d", &cards[i]);
		}
		for (i = length - 1; i >= 0; --i) {
			printf("%d", cards[i]);
			printf(i ? " " : "\n");
		}		
	}
	else {
		int x;
		for (i = 0; i < length; ++i) {
			scanf("%d", &x);
			printf("%d", x);
			printf(i == length - 1 ? "\n" : " ");
		}
	}
	return 0;
}