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
#include <cstdio>

#define MAX_SIZE (1 << 21)

using namespace std;

int cardDeck[MAX_SIZE];

int main() {
    int n, t, cardDeckLength;

    #ifdef _PA_USE_TEST_INPUT_FILE_
    freopen("input.txt","rt",stdin);
    #endif

    scanf("%d %d ", &n, &t);

    cardDeckLength = 1 << n;

    for (int i = 0; i < cardDeckLength; i++) {
        scanf("%d ", &cardDeck[i]);
    }

    if (t % 2 == 0) {
        for (int i = 0; i < cardDeckLength; i++) {
            printf("%d ", cardDeck[i]);
        }
    } else {
        for (int i = cardDeckLength - 1; i >= 0; i--) {
            printf("%d ", cardDeck[i]);
        }
    }

    return 0;
}