#include <cstdio> #include <algorithm> using namespace std; const int MAX_SIZE = 2<<20; int n, t; int a[MAX_SIZE]; int main() { scanf("%d%d", &n, &t); size_t size = 2 << (n-1); for (int i = 0; i < size; i++) { scanf("%d", a + i); } if (t % 2 == 1) { std::reverse(a, a+size); } for (int i = 0; i < size; i++) { printf("%d ", a[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 | #include <cstdio> #include <algorithm> using namespace std; const int MAX_SIZE = 2<<20; int n, t; int a[MAX_SIZE]; int main() { scanf("%d%d", &n, &t); size_t size = 2 << (n-1); for (int i = 0; i < size; i++) { scanf("%d", a + i); } if (t % 2 == 1) { std::reverse(a, a+size); } for (int i = 0; i < size; i++) { printf("%d ", a[i]); } return 0; } |