1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#include <cstdio>
#include <vector>
#include <algorithm>

int main () {
   int n,t,ai;
   scanf("%d%d",&n,&t);
   int size=1<<n;
   std::vector<int> data;
   for(int i=0; i<size; ++i) {
      scanf("%d",&ai);
      data.push_back(ai);
   }
   if(t%2) std::reverse(data.begin(), data.end());
   for(int a : data)
      printf("%d ", a);
   printf("\n");

   return 0;
}