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 <iostream>
#include <cstdio>
#include<algorithm>
#include <vector>
#include <stdexcept>
#define ll long long
using namespace std;

using namespace std;

int main()
{
    int n, t;
    scanf("%d %d", &n,&t);
    n = 1<<n;
    vector<int> A(n);
    for(int i=0;i<n;i++){
        scanf("%d", &(A[i]));
    }
    if(t%2) {
        int a =0;int b = n-1;
        while(b>a){
            swap(A[a],A[b]);
            a++;b--;
        }
    }
    for(int i=0;i<n;i++)printf("%d ",A[i]);
    printf("\n");
    return 0;
}