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
31
#include <stdio.h>
#include <stdlib.h>

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

  int i = 0, s = 1;
  for (i = 0; i < n; ++i) {
    s *= 2;
  }

  int *a = (int *) malloc (s * sizeof(int));
  for (i = 0; i < s; ++i) {
    scanf("%d", &(a[i]));
  }
  
  //printf("%d %d %d", n, t, s);

  if (t % 2 == 0) {
    for (i = 0; i < s; ++i) {
      printf("%d ", a[i]);
    }
  } else {
    for (i = 0; i < s; ++i) {
      printf("%d ", a[s - i - 1]);
    }
  }
  printf("\n");
  return 0;
}