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

using namespace std;

int main()
{
    int n, t;
    cin>>n>>t;
    int x = pow(2.0,n);
    vector<int> talia(x);
    for(int a=0; a<x; a++)
        cin>>talia[a];
    if(t%2)
        reverse(talia.begin(), talia.end());
    for(vector<int>::iterator i = talia.begin(); i != talia.end(); i++)
            cout<< *i << " ";
    return 0;
}