1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#include "cstdio"
using namespace std;
long long n, t, k = 1, tab[1100005];
int main()
{
    scanf ("%lld%lld", &n, &t);
    for (int i = 0; i < n; i++) k *= 2;
    for (int i = 0; i < k; i++) scanf ("%lld", &tab[i]);
    if (t % 2 == 0) for (int i = 0; i < k; i++) printf ("%lld ", tab[i]);
    else for (int i = k - 1; i >= 0; i--) printf ("%lld ", tab[i]);

    return 0;
}