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 <cstdlib>
#include <cstdio>
using namespace std;

int main(){
	int t, n;
	
	scanf("%d %d", &n, &t);
	
	int size = (1 << n);
	bool rev = (t % 2 != 0);
	int *numbers = new int[size];
	
	for(int i=0; i<size; i++)
		scanf("%d", &numbers[i]);
	
	if(!rev){
		for(int i=0; i<size; i++)
			printf("%d ", numbers[i]);
	}else{
		for(int i=size-1; i>=0; i--)
			printf("%d ", numbers[i]);
	}
	
	delete [] numbers;
	return 0;
}