1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
#include <stdio.h>

int cards[1<<20];

int main(int argc, char **argv)
{
	int n,t;
    scanf("%d%d",&n,&t);
    int num_cards = 1<<n;
    for(int i=0;i<num_cards;i++)
        scanf("%d",&cards[i]);
    
    if(t&1)
        for(int i=num_cards-1;i>=0;i--)
            printf("%d ", cards[i]);
    else
        for(int i=0;i<num_cards;i++)
            printf("%d ", cards[i]);
    putchar('\n');
	return 0;
}