#include <iostream> #include <string> #include <sstream> #include <vector> int main() { unsigned n, t; scanf("%u %u", &n, &t); unsigned total_nums = 0x1 << n; std::vector<unsigned> nums; nums.reserve(total_nums + 1); for (unsigned i = 0; i < total_nums; i++) { unsigned num; std::cin >> num; nums.push_back(num); } if (t % 2) { for (auto it = nums.crbegin(); it != nums.crend(); it++) std::cout << *it << " "; } else { for (auto it = nums.cbegin(); it != nums.cend(); it++) std::cout << *it << " "; } 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 | #include <iostream> #include <string> #include <sstream> #include <vector> int main() { unsigned n, t; scanf("%u %u", &n, &t); unsigned total_nums = 0x1 << n; std::vector<unsigned> nums; nums.reserve(total_nums + 1); for (unsigned i = 0; i < total_nums; i++) { unsigned num; std::cin >> num; nums.push_back(num); } if (t % 2) { for (auto it = nums.crbegin(); it != nums.crend(); it++) std::cout << *it << " "; } else { for (auto it = nums.cbegin(); it != nums.cend(); it++) std::cout << *it << " "; } return 0; } |