#include <algorithm> #include <cstdio> #include <vector> using namespace std; int main() { int t, n; scanf("%d %d\n", &n, &t); int deckSize = (1 << n); vector<int> a; for (int i = 0; i < deckSize; ++i) { int ai; scanf("%d", &ai); a.push_back(ai); } if (t % 2 == 1) { reverse(a.begin(), a.end()); } for (int i = 0; i < deckSize - 1; ++i) printf("%d ", a[i]); printf("%d\n", a[deckSize - 1]); 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 <algorithm> #include <cstdio> #include <vector> using namespace std; int main() { int t, n; scanf("%d %d\n", &n, &t); int deckSize = (1 << n); vector<int> a; for (int i = 0; i < deckSize; ++i) { int ai; scanf("%d", &ai); a.push_back(ai); } if (t % 2 == 1) { reverse(a.begin(), a.end()); } for (int i = 0; i < deckSize - 1; ++i) printf("%d ", a[i]); printf("%d\n", a[deckSize - 1]); return 0; } |