#include <bits/stdc++.h> const int N = 1 << 21; int a[N]; int main() { int n, t; scanf("%d%d", &n, &t); for (int i = 0; i < (1 << n); ++i) scanf("%d", a + i); if (t & 1) std::reverse(a, a + (1 << n)); for (int i = 0; i < (1 << n); ++i) { if (i) putchar(' '); printf("%d", a[i]); } puts(""); return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #include <bits/stdc++.h> const int N = 1 << 21; int a[N]; int main() { int n, t; scanf("%d%d", &n, &t); for (int i = 0; i < (1 << n); ++i) scanf("%d", a + i); if (t & 1) std::reverse(a, a + (1 << n)); for (int i = 0; i < (1 << n); ++i) { if (i) putchar(' '); printf("%d", a[i]); } puts(""); return 0; } |