1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    vector<int> res;
    int n, t, a;
    cin >> n >> t;
    for (int i=0; i < (1 << n); i++) {
        cin >> a;
        res.push_back(a);
    }
    if (t % 2 == 1)
        reverse(res.begin(), res.end());
    for (auto x : res)
        cout << x << " ";
    return 0;
}