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