1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Rafał Nowak

#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;

vector<int> V;

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

  for (int i=0; i<(1<<n); i++)
  {
    scanf("%d", &x);
    V.push_back(x);
  }
  if ( t%2==1 ) reverse( V.begin(), V.end() );
  for (auto x : V) printf("%d ", x);
  return 0;
}