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
54
55
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/* 
 * File:   tas.cc
 * Author: Administrator2
 *
 * Created on 22 listopad 2016, 22:58
 */

#include <vector>
#include <cmath>
#include <iostream>

using namespace std;

/*
 * 
 */
int main(int argc, char** argv) {
    long n;

    cin>>n;

    long long t;

    cin>>t;

    long deckSize = pow(2, n);
    vector<long> a(deckSize);

    for (long &elem : a) {
        cin>>elem;
    }

    if (t % 2 == 0) {
        cout<<a[0];
        for (long i=1;i<deckSize;++i) {
            cout<<a[i];
        }
    }
    else{
        long i=deckSize-1;
        cout<<a[i];
        for (--i;i>=0;--i) {
            cout<<a[i];
        }
    }
    cout<<endl;

    return 0;
}