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
#include <iostream>
#include <vector>
int main()
{
    using namespace std;
    ios_base::sync_with_stdio( false );
    using integer = uint32_t;
    integer n, t;
    cin >> n >> t;
    if( t & 1 )
    {
        vector< integer > v( 1 << n );
        for( auto i = v.begin(); i != v.end(); ++i ) cin >> *i;
        cout << v.back();
        for( auto i = v.rbegin() + 1; i != v.rend(); ++i ) cout << ' ' << *i;
    }
    else
    {
        integer k { integer( 1 << n ) }, a;
        cin >> a;
        cout << a;
        for( integer i { 1 }; i < k; ++i )
        {
            cin >> a;
            cout << ' ' << a;
        }
    }
    return 0;
}