1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int k[1500000];
main(){
	int n,t;
	cin>>n>>t;
	for(int i=1;i<=pow(2,n);++i){
		scanf("%d",&k[i]);
	}
	if(t%2==0){
		for(int i=1;i<=pow(2,n);++i){
			printf("%d ",k[i]);
		}
	}
	else
		for(int i=pow(2,n);i>=1;--i){
			printf("%d ",k[i]);
		}
}