#include <cstdio> #include <algorithm> const int N = 20; int n, t, a[1 << N]; int main() { scanf("%d%d", &n, &t); const int m = 1 << n; for (int i = 0; i < m; ++i) scanf("%d", &a[i]); if (t & 1) std::reverse(a, a + m); for (int i = 0; i < m; ++i) printf("%d%c", a[i], i == m - 1 ? '\n' : ' '); return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | #include <cstdio> #include <algorithm> const int N = 20; int n, t, a[1 << N]; int main() { scanf("%d%d", &n, &t); const int m = 1 << n; for (int i = 0; i < m; ++i) scanf("%d", &a[i]); if (t & 1) std::reverse(a, a + m); for (int i = 0; i < m; ++i) printf("%d%c", a[i], i == m - 1 ? '\n' : ' '); return 0; } |