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
#include<bits/stdc++.h>
#define ll long long
using namespace std;

const ll N = 1200000;

ll n, t, a;
ll tab[N];

int main()
{
    scanf("%lld %lld", &n , &t);
    n = pow(2,n);

    if(t%2 == 0)
    {
        for(ll i = 0; i < n; ++i)
        {
            scanf("%lld",&a);
            printf("%lld ",a);
        }
        printf("\n");
    }
    else
    {
        for(ll i = 0; i < n; ++i)
            scanf("%lld",&tab[i]);
        for(int i = n-1; i >= 0; --i)
            printf("%lld ",tab[i]);
        printf("\n");
    }

return 0;
}