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<cstdio>

int main(int argc, char** argv){
  int n, t, tmp, num;
  int cards[1048576];
  scanf("%d %d", &n, &t);
  num = 2<<(n-1);
  for(int i=0; i < num; i++){
    scanf("%d", &tmp);
    cards[i] = tmp;
  }
  
  if(t%2)
    for(int i = num - 1 ; i >= 0; i--){
      printf("%d", cards[i]);
      if ( i != 0 ) printf(" ");
    }
  
  else
    for(int i=0; i < num ; i++){
      printf("%d", cards[i]);
      if ( i != num-1 ) printf(" ");
    }
  printf("\n");
  return 0;
}