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
30
31
32
#include <iostream>
#include <algorithm>
#include <vector>

int main() {
	unsigned n, t, max;
	std::cin >> n;
	std::cin >> t;
	max = 1 << n;
	if(t & 1)
	{
		std::vector<unsigned> values(max);
			for(unsigned i = 0; i < max; ++i)
			{
				std::cin >> values[i];
			}
			for(int i = max -1; i >= 0; --i)
			{
				std::cout << values[i] << ' ';
			}
	}
		else
		{
			for(unsigned i = 0; i < max; ++i)
			{
				unsigned val;
				std::cin >> val;
				std::cout << val << ' ';
			}
		}
	return 0;
}