#include <cstdio> #include <vector> using std::vector; int main() { int n, t; scanf("%d%d", &n, &t)?:0; n = 1 << n; t %= 2; vector<int> a; a.resize(n); for (int i = 0; i < n; i++) scanf("%d", &a[i])?:0; for (int i = 0; i < n; i++) printf("%d ", t ? a[n - i - 1] : a[i]); }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | #include <cstdio> #include <vector> using std::vector; int main() { int n, t; scanf("%d%d", &n, &t)?:0; n = 1 << n; t %= 2; vector<int> a; a.resize(n); for (int i = 0; i < n; i++) scanf("%d", &a[i])?:0; for (int i = 0; i < n; i++) printf("%d ", t ? a[n - i - 1] : a[i]); } |