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
40
41
42
// Piotr Golda

#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
using namespace std;

unsigned int T, N;

int main()
{

	scanf("%ud", &N);
	scanf("%ud", &T);
	unsigned int S = pow(2, N);
	if (T % 2)
	{
		vector<unsigned int> V;
		V.resize(S);
		for (unsigned int i = 0; i < S; ++i)
		{
			scanf("%u", &V[i]);
		}
		for (int i = S-1; i >= 0; --i)
		{
			printf("%u ", V[i]);
		}
	}
	else
	{
		int x;

		for (int i = S-1; i >= 0; --i)
		{
			scanf("%u", &x);
			printf("%u ", x);
		}
	}
	printf("\n");
	return 0;
}