1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
/* 2016
 * Maciej Szeptuch
 */
#include <cstdio>

int number[1048576];
int operations;
int size;

int main(void)
{
    scanf("%d %d", &size, &operations);
    operations &= 1;
    for(int s = 0; s < (1 << size); ++ s)
        scanf("%d", &number[s]);

    for(int s = 0; s < (1 << size); ++ s)
        printf("%d ", number[operations ? (1 << size) - 1 - s : s]);

    puts("");
    return 0;
}