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
#include <iostream>
#include <math.h>

using namespace std;

int queueCard[20000000];

int main()
{
   int n;                           //2^n iloϾ kart
   int t;                           //Iloœæ przetasowañ

   cin>>n;
   cin>>t;

   int lenght = pow(2, n);

   for (int i=0; i<lenght; i++)
   {
      cin>>queueCard[i];
   }

   if (t%2 == 1)
   {
      for (int i=(lenght-1); i>=0; i--)
      {
         cout<<queueCard[i]<<" ";
      }
   }
   else
      for (int i=0; i<lenght; i++)
      {
         cout<<queueCard[i]<<" ";
      }
   return 0;
}