1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Tasowanie B

#include <cstdio>

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