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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long ll;

vector<ll> ciag;

ll fp(ll x, ll y)
{
    if(y == 1)
        return x;
    
    if(y % 2)
        return x * fp(x, y-1);
    
    ll pom = fp(x, y/2);
    return pom * pom;
}

int main()
{
    ios_base::sync_with_stdio(0);

    ll n, t;
    cin >> n >> t;

    n = fp(2, n);

    for(ll i=0; i<n; i++)
    {
        ll a;
        cin >> a;
        ciag.push_back(a);
    }

    if((t % 2) == 0)
    {
        for(int i=0; i<ciag.size(); i++)
        {
            cout << ciag[i] << " ";
        }
    }
    else
    {
        for(int i=ciag.size()-1; i>=0; i--)
        {
            cout << ciag[i] << " ";
        }
    }

    cout<<"\n";

    return 0;
}