#include <cstdio> #include <vector> #include <cinttypes> #include <algorithm> int main() { uint32_t n, t; scanf("%u %u", &n, &t); const uint32_t npow = 1 << n; std::vector<uint32_t> A; A.resize(npow); for (int i = 0; i < npow; ++i) { uint32_t a; scanf("%d", &a); A[i] = a; } if (t&1) { std::reverse(A.begin(), A.end()); } for (uint32_t a : A) { printf("%u ", a); } }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #include <cstdio> #include <vector> #include <cinttypes> #include <algorithm> int main() { uint32_t n, t; scanf("%u %u", &n, &t); const uint32_t npow = 1 << n; std::vector<uint32_t> A; A.resize(npow); for (int i = 0; i < npow; ++i) { uint32_t a; scanf("%d", &a); A[i] = a; } if (t&1) { std::reverse(A.begin(), A.end()); } for (uint32_t a : A) { printf("%u ", a); } } |