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
#include <bits/stdc++.h>

using namespace std;

int main() {

int n;
int t;
cin >> n >> t;
vector<int> tab(1<<n);
for (int i = 0; i< 1<<n;i++){

  cin >> tab[i];
}

if (t%2 ==1){

    reverse(tab.begin(),tab.end());
}
for (int i = 0; i< 1<<n;i++){

  cout << tab[i] << ' ';
}
return 0;

}