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
//
// Created by Michal Stobierski on 21.11.16.
//
#include <iostream>
#include <bits/stdc++.h>
using namespace std;

#define MAX_N 20
int cards[(1<<MAX_N)+9];

int main() {
    ios_base::sync_with_stdio(false);
    int n, t;
    cin >> n >> t;

    for (auto i = 1; i <= (1<<n); ++i) {
        cin >> cards[i];
    }
    if (t&1) {
        for (auto i = (1<<n); i >= 1; --i) {
            cout << cards[i] << " ";
        }
    } else {
        for (auto i = 1; i <= (1<<n); ++i) {
            cout << cards[i] << " ";
        }
    }
    cout << endl;
    return 0;
}