1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#include <cstdio>
#define siz 1050000
int n, a,ind;
int tab[siz];
int main()
{
	scanf("%d%d", &n, &a);
	ind = (1<<n)-1;
	for(int i=0;i<(1<<n);i++)
	{
		if(a%2==0)scanf("%d", &tab[i]);
		else scanf("%d", &tab[ind]);
		ind--;
	}
	for(int i=0;i<(1<<n);i++)
	{
		printf("%d ", tab[i]);
	}
	return 0;
}