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 <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
  int n, t;
  scanf("%d%d", &n, &t);

  vector<int> x;
  for (int i = 0; i < (1 << n); i++) {
    int v;
    scanf("%d", &v);
    x.push_back(v);
  }

  if ((t & 1) == 0) {
    for (int v : x) {
      printf("%d ", v);
    }
  } else {
    for (int i = x.size() - 1; i >= 0; i--) {
      printf("%d ", x[i]);
    }
  }

  return 0;
}