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
32
33
#include <cstdio>
using namespace std;

int write_on_cards[1048576];

int main() {
  int exponent;
  long long int number_of_shuffle;
  long long int number_of_iteration = 1;

  scanf("%d%lld", &exponent, &number_of_shuffle);

  for(int i = 0; i < exponent; ++i) {
      number_of_iteration *= 2;
  }

  for(int i = 0; i < number_of_iteration; ++i) {
      scanf("%d", &write_on_cards[i]);
  }

  if(number_of_shuffle%2 == 0) {
      for(int i = 0; i < number_of_iteration; ++i) {
          printf("%d ", write_on_cards[i]);
      }
  }
  else {
      for(int i = number_of_iteration-1; i >= 0; --i) {
          printf("%d ", write_on_cards[i]);
      }
  }
  printf("\n");
  return 0;
}