/* Arek Wróbel
*
* Konkurs: Potyczki Algorytmiczne 2016, runda 1B
* Zadanie: Tasowanie
*/
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define REP(I, N) for(int I=0; I<(N); ++I)
#define FOR(I, M, N) for(int I=(M); I<=(N); ++I)
#define FORD(I, M, N) for(int I=(M); I>=(N); --I)
#define FOREACH(IT, CON) for(__typeof(CON.begin()) IT=CON.begin(); IT!=CON.end(); ++IT)
#define ST first
#define ND second
#define MP make_pair
#define PB push_back
#define SIZE(con) ((int)((con).size()))
const int INF=1000000000;
const LL INFLL=1000000000000000000LL;
int n, t;
int a[2000000];
int main()
{
scanf("%d%d", &n, &t);
n = 1<<n;
REP(i, n) {
scanf("%d", &a[i]);
}
if (t % 2) {
reverse(a, a+n);
}
REP(i, n) {
printf("%d ", a[i]);
}
printf("\n");
return 0;
}
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 | /* Arek Wróbel * * Konkurs: Potyczki Algorytmiczne 2016, runda 1B * Zadanie: Tasowanie */ #include <cstdio> #include <algorithm> #include <cmath> #include <vector> using namespace std; typedef long long LL; typedef pair<int, int> PII; typedef vector<int> VI; #define REP(I, N) for(int I=0; I<(N); ++I) #define FOR(I, M, N) for(int I=(M); I<=(N); ++I) #define FORD(I, M, N) for(int I=(M); I>=(N); --I) #define FOREACH(IT, CON) for(__typeof(CON.begin()) IT=CON.begin(); IT!=CON.end(); ++IT) #define ST first #define ND second #define MP make_pair #define PB push_back #define SIZE(con) ((int)((con).size())) const int INF=1000000000; const LL INFLL=1000000000000000000LL; int n, t; int a[2000000]; int main() { scanf("%d%d", &n, &t); n = 1<<n; REP(i, n) { scanf("%d", &a[i]); } if (t % 2) { reverse(a, a+n); } REP(i, n) { printf("%d ", a[i]); } printf("\n"); return 0; } |
English