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
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int a[2000000];

int main(){
	int b, c;
	scanf("%d %d", &b, &c);
	b = pow(2, b);
	for (int i = 1; i <= b; i++){
		scanf("%d", &a[i]);
	}
	if (c % 2 == 0)
		for (int i = 1; i <= b; i++){
			printf("%d ", a[i]);
		}
	else
		for (int i = b; i >= 1; i--){
			printf("%d ", a[i]);
		}
	//system("pause");
}