#include <cinttypes> #include <cstdio> using namespace std; int main(int argc, const char* argv[]) { uint32_t n, t; scanf("%u %u", &n, &t); uint32_t cnt = 1 << n; uint32_t* cards = new uint32_t[cnt]; for (uint32_t i = 0; i < cnt; ++i) { scanf("%u", &cards[i]); } if ((t & 1) == 0) { for (uint32_t i = 0; i < cnt; ++i) { if (i < cnt - 1) { printf("%u ", cards[i]); } else { printf("%u\n", cards[i]); } } } else { for (uint32_t i = cnt; i > 0; --i) { if (i > 1) { printf("%u ", cards[i - 1]); } else { printf("%u\n", cards[i - 1]); } } } delete [] cards; 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 | #include <cinttypes> #include <cstdio> using namespace std; int main(int argc, const char* argv[]) { uint32_t n, t; scanf("%u %u", &n, &t); uint32_t cnt = 1 << n; uint32_t* cards = new uint32_t[cnt]; for (uint32_t i = 0; i < cnt; ++i) { scanf("%u", &cards[i]); } if ((t & 1) == 0) { for (uint32_t i = 0; i < cnt; ++i) { if (i < cnt - 1) { printf("%u ", cards[i]); } else { printf("%u\n", cards[i]); } } } else { for (uint32_t i = cnt; i > 0; --i) { if (i > 1) { printf("%u ", cards[i - 1]); } else { printf("%u\n", cards[i - 1]); } } } delete [] cards; return 0; } |