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
#include <stdio.h>
#include <math.h>
#define get(a) scanf("%d",&a)

using namespace std;

int arr [1148577];

int main () {
  int n, f;

  get (n);
  get (f);
  n = pow (2, n);
  //printf ("%d %d\n", n, f);
  for (int i = 0; i < n ; i ++) {
    get (arr[i]);
  }
  if(f % 2 == 0)
    for (int i = 0 ; i < n ; i ++) {
      printf ("%d ", arr [i]);
    }
  else
    for (int i = n - 1; i >= 0; i --) {
      printf ("%d ", arr [i]);
    }
}