#include<algorithm> #include<cassert> #include<cassert> #include<cctype> #include<cmath> #include<cstdio> #include<cstdlib> #include<cstring> #include<deque> #include<iostream> #include<list> #include<map> #include<queue> #include<set> #include<string> #include<vector> using namespace std; typedef long long LL; typedef vector<int> VI; #define REP(i,n) for(int i=0;i<(n);i++) #define FOR(i,a,b) for(int i=(a);i<=(b);i++) #define FORD(i,a,b) for(int i=(a);i>=(b);i--) #define FOREACH(i,c) for(__typeof((c).begin())i = (c).begin();i!=(c).end(); ++i) int main() { int n, t; scanf("%d %d", &n, &t); int m = 1; REP(i, n) m *= 2; VI a(m); REP(i, m) { scanf("%d", &a[i]); } if ((t & 1) == 0) { REP(i, m) { cout << a[i] << " "; } cout << endl; } else { REP(i, m) { cout << a[m-i-1] << " "; } cout << endl; } 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 48 49 | #include<algorithm> #include<cassert> #include<cassert> #include<cctype> #include<cmath> #include<cstdio> #include<cstdlib> #include<cstring> #include<deque> #include<iostream> #include<list> #include<map> #include<queue> #include<set> #include<string> #include<vector> using namespace std; typedef long long LL; typedef vector<int> VI; #define REP(i,n) for(int i=0;i<(n);i++) #define FOR(i,a,b) for(int i=(a);i<=(b);i++) #define FORD(i,a,b) for(int i=(a);i>=(b);i--) #define FOREACH(i,c) for(__typeof((c).begin())i = (c).begin();i!=(c).end(); ++i) int main() { int n, t; scanf("%d %d", &n, &t); int m = 1; REP(i, n) m *= 2; VI a(m); REP(i, m) { scanf("%d", &a[i]); } if ((t & 1) == 0) { REP(i, m) { cout << a[i] << " "; } cout << endl; } else { REP(i, m) { cout << a[m-i-1] << " "; } cout << endl; } return 0; } |