1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int p[21]={1};

int main()
{
    for(int i=1; i<21; ++i)
        p[i] = 2*p[i-1];

    int n, t;
    cin >> n >> t;
    int pn = p[n];
    vector<int> v(pn);
    for(int i=0; i<pn; ++i)
        cin >> v[i];
    if(t%2==1)
        reverse(v.begin(), v.end());
    for(int i=0; i<pn; ++i)
        cout << v[i] << " ";
    cout << endl;
}