1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int n, t, size=1, initial, iter, end;
	vector<int> numbers;
	cin >> n >> t;
	for(int i = 0; i < n ; i++) size *= 2;
	numbers.resize(size);
	for(int i = 0; i < size; i++) cin >> numbers[i];
	iter = t%2 ? -1 : 1;
	initial = t%2 ? size - 1 : 0;
	end = t%2 ? -1 : size;
	for(int i = initial; i != end; i += iter)
		cout << numbers[i] << " ";
	return 0;  
}