1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#include<iostream>
#include<cstdio>
using namespace std;
int n,k,t[2000000];
int main()
{
    scanf("%d%d", &n, &k);
    int x=1;
    for(int i=1;i<=n;i++)x*=2;
    for(int i=1;i<=x;i++)scanf("%d", &t[i]);
    if(k%2==0)for(int i=1;i<=x;i++)printf("%d ", t[i]);
    else for(int i=x;i>=1;i--)printf("%d ", t[i]);
}