#include <cstdio> #include <vector> #include <algorithm> using namespace std; int n, t, N; vector <int> v; int main() { scanf("%d %d", &n, &t); N = 1 << n; v.resize(N); for(int i = 0; i < N; ++i) { scanf("%d", &v[i]); } if(t % 2 == 1) reverse(v.begin(), v.end()); for(int i = 0; i < N; ++i) { printf("%d ", v[i]); } puts(""); 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 | #include <cstdio> #include <vector> #include <algorithm> using namespace std; int n, t, N; vector <int> v; int main() { scanf("%d %d", &n, &t); N = 1 << n; v.resize(N); for(int i = 0; i < N; ++i) { scanf("%d", &v[i]); } if(t % 2 == 1) reverse(v.begin(), v.end()); for(int i = 0; i < N; ++i) { printf("%d ", v[i]); } puts(""); return 0; } |