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
#include <iostream>
#include <vector>
#include <iterator>

int pow2(int n) {
    return 2 << n-1;
}

int main(void) {
    int pow;
    int cardNum;
    int shuffleNum;
    
    std::cin >> pow;
    cardNum = pow2(pow);
    std::cin >> shuffleNum;
    
    int buff;
    if(shuffleNum % 2 == 0) {
        for(int i=0; i<cardNum; ++i) {
            std::cin >> buff;
            std::cout << buff << " ";
        }
    } else {
        std::vector<int> cards;
        cards.reserve(cardNum);
        for(int i=0; i<cardNum; ++i) {
            std::cin >> buff;
            cards.push_back(buff);
        }
        for(int i=cardNum-1; i>=0; --i) {
        	std::cout << cards[i] << " ";
        }
    }
    
    return 0;
}