# include <bits/stdc++.h> const int MN = (1 << 20) + 44; int a[MN]; int main() { int n, t; scanf("%d%d", &n, &t); int N = 1 << n; for (int i = 0; i < N; ++i) scanf("%d", a + i); if (t % 2) std::reverse(a, a + N); for (int i = 0; i < N; ++i) printf("%d%c", a[i], i == N - 1 ? '\n' : ' '); }
1 2 3 4 5 6 7 8 9 10 11 | # include <bits/stdc++.h> const int MN = (1 << 20) + 44; int a[MN]; int main() { int n, t; scanf("%d%d", &n, &t); int N = 1 << n; for (int i = 0; i < N; ++i) scanf("%d", a + i); if (t % 2) std::reverse(a, a + N); for (int i = 0; i < N; ++i) printf("%d%c", a[i], i == N - 1 ? '\n' : ' '); } |