#include <cstdio> #include <algorithm> #include <vector> using namespace std; int main() { int n, t; scanf("%d %d", &n, &t); int cards = 2 << (n - 1); vector<int> numbers; for (int i = 0; i < cards; ++i) { int number; scanf("%d", &number); numbers.push_back(number); } if (t % 2 == 1) { reverse(numbers.begin(), numbers.end()); } for (auto number = numbers.begin(); number != numbers.end(); ++number) { printf("%d ", *number); } 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 | #include <cstdio> #include <algorithm> #include <vector> using namespace std; int main() { int n, t; scanf("%d %d", &n, &t); int cards = 2 << (n - 1); vector<int> numbers; for (int i = 0; i < cards; ++i) { int number; scanf("%d", &number); numbers.push_back(number); } if (t % 2 == 1) { reverse(numbers.begin(), numbers.end()); } for (auto number = numbers.begin(); number != numbers.end(); ++number) { printf("%d ", *number); } return 0; } |