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
37
38
39
#include <iostream>
#include <math.h>

using namespace std;

const int MAX_N = 20;
const int MAX_SIZE = pow(2, MAX_N);

int n;
int t;
int size;
bool reversed;

int *deck;

void shuffle()
{

}

int main(int argc, char **argv)
{
	cin >> n >> t;
	size = pow(2, n);
	reversed = t % 2;

	deck = new int[size];

	for(int i = 0; i < size; i++)
	{
		cin >> deck[i];
	}

	for(int i = 0; i < size; i++)
	{
		cout << (i > 0 ? " " : "") << deck[reversed ? size - i - 1 : i];
	}
	return 0;
}