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
33
34
35
36
// Solution to 1TAS
// Author: Michal Czuczman <michal.czuczman@gmail.com>
// created on Mon Nov 21 20:48:33 CET 2016

#include <iostream>
#include <vector>

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	int n, t;
	cin >> n >> t;

	int size = 1 << n;

	if(t & 1) {
		vector<int> v;
		v.reserve(size);
		for(int i = 0; i < size; ++i) {
			int a;
			cin >> a;
			v.push_back(a);
		}
		for(int i = v.size() - 1; i >= 0; --i) {
			cout << v[i] << " ";
		}
	} else {
		for(int i = 0; i < size; ++i) {
			int a;
			cin >> a;
			cout << a << " ";
		}
	}
}