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
#include <stdio.h>

long int karty[1048576];
long int n,t;
long int pot2[22];

void licz_pot(void)
{
	int i;
	pot2[0]=1;
	for (i=1;i<22;++i)
	  pot2[i]=2*pot2[i-1];
	
	return;
}

int main()
{
	int i,NN;
	scanf("%ld %ld",&n,&t);
	licz_pot();
	NN=pot2[n];
	for(i=0;i<NN;++i)
	  scanf("%ld", &(karty[i]));
	  
	if (t%2) for(i=NN-1;i>=0;--i) {if (i==0) printf("%ld\n",karty[i]); else printf("%ld ",karty[i]);} 
    else for(i=0;i<NN;i++) {if (i==NN-1) printf("%ld\n",karty[i]); else printf("%ld ",karty[i]);}
	
	return 0;
}