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
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;

int main(int argc, char** argv) {
	int n, t;
	vector<int>T;
	cin >> n >> t;
	for (int i = 0; i < pow(2, n); i++) {
		int temp;
		cin >> temp;
		T.push_back(temp);
	}
	if (t % 2 == 0) {
		for (int i = 0; i < T.size(); i++) {
			cout << T[i] << " ";
		}
	}
	else if (t % 2 != 0) {
		for (int i = T.size()-1; i >= 0; i--) {
			cout << T[i] << " ";
		}
	}

	return 0;
}