#include <bits/stdc++.h> using namespace std; #define REP(i,a,b) for (int i = (a); i <= (b); ++i) #define REPD(i,a,b) for (int i = (a); i >= (b); --i) #define FORI(i,n) REP(i,1,n) #define FOR(i,n) REP(i,0,int(n)-1) #define mp make_pair #define pb push_back #define sz(x) int((x).size()) #define dbg(v) cerr << #v << " = " << (v) << endl; #define FOREACH(i,t) for (__typeof(t.begin()) i = t.begin(); i != t.end(); ++i) #define fi first #define se second #define pii pair<int,int> const int INF = 2000000000; const int MAXM = 2197152; int tab[MAXM]; int main() { int n,t; scanf("%d %d", &n, &t); int m = (1<<n); for (int i=0;i<m;++i) { scanf("%d", &tab[i]); } if (t%2 == 1) { reverse(tab, tab+m); } for (int i=0;i<m;++i) { printf("%d ", tab[i]); } 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 | #include <bits/stdc++.h> using namespace std; #define REP(i,a,b) for (int i = (a); i <= (b); ++i) #define REPD(i,a,b) for (int i = (a); i >= (b); --i) #define FORI(i,n) REP(i,1,n) #define FOR(i,n) REP(i,0,int(n)-1) #define mp make_pair #define pb push_back #define sz(x) int((x).size()) #define dbg(v) cerr << #v << " = " << (v) << endl; #define FOREACH(i,t) for (__typeof(t.begin()) i = t.begin(); i != t.end(); ++i) #define fi first #define se second #define pii pair<int,int> const int INF = 2000000000; const int MAXM = 2197152; int tab[MAXM]; int main() { int n,t; scanf("%d %d", &n, &t); int m = (1<<n); for (int i=0;i<m;++i) { scanf("%d", &tab[i]); } if (t%2 == 1) { reverse(tab, tab+m); } for (int i=0;i<m;++i) { printf("%d ", tab[i]); } return 0; } |