1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
#include <iostream>
#include <algorithm>
using namespace std;
const int N = (1<<20)+5;
int tb[N];
int main()
{
    ios_base::sync_with_stdio(false);
    int n, t;
    cin >> n >> t;
    for(int i = 0; i < (1<<n); ++i) cin >> tb[i];
    if(t&1) reverse(tb, tb+(1<<n));
    for(int i = 0; i < (1<<n); ++i) cout << tb[i] << ' ';
    cout << endl;
    return 0;
}