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
#include <iostream>
using namespace std;

unsigned int nums[256*256*16];
int main()
{
  unsigned int n;
  unsigned int t;
  cin >> n;
  cin >> t;
  unsigned int counter = 1 << n;
  for (size_t i=0; i<counter; ++i)
    cin >> nums[i];
  if (t&1)
  {
    for (size_t i=counter; i>0; --i)
      cout << nums[i-1] << " ";
  }
  else
  {
    for (size_t i=0; i<counter; ++i)
      cout << nums[i] << " ";
  }
  return 0;
}