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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <iostream>
#include <vector>
using namespace std;
vector <int> tab[3];

long long pot( int a, int n)
{
  long long w = 1;

  while(n>0)
  {
    if (n%2 == 1)
      w *= a;

    a*= a;
    n/=2;
  }
  return w;
}


int main()
{
std::ios_base::sync_with_stdio(0);

int nn, l, ile, aa;
cin>>nn>>l;

ile=pot(2, nn );

//cout<<ile;
if (l%2==0){

for (int i=0; i<ile; i++)
   {cin>>aa;
    cout<<aa<<" ";

   }

return 0;
   }
   else{
    for (int i=0; i<ile; i++)
   {cin>>aa;
tab[1].push_back(aa);

   }
        for (int i=ile-1; i>=0; i--)
        cout<<tab[1][i]<<" ";
   }

  // cout<<tab[1][ile-1];
}