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
28
29
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int n, t;
	cin >> n >> t;
	int no = pow(2,n);
	int temp;
	vector<int> array;
	for(int i = 0; i < no; ++i){
		cin >> temp;
		array.push_back(temp);
	}
	if(t % 2 == 0){
		for(int el : array)
			cout << el <<" ";
	}
	else{
		int size = (int) array.size();
		for(int i = size - 1; i >= 0; --i)
			cout<<array[i]<<" ";
	}
	cout<<endl;
	return 0;
}