#include <bits/stdc++.h> using namespace std; const int MAXN = 2e6+6; int n,k; vector<int> v; int main(){ scanf("%d%d", &n, &k); n = pow(2, n); for (int i = 1; i <= n; ++i){ int x; scanf("%d", &x); v.push_back(x); } if (k % 2 == 1) reverse(v.begin(), v.end()); for (int i = 0; i < (int)v.size(); ++i) printf("%d ", v[i]); }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #include <bits/stdc++.h> using namespace std; const int MAXN = 2e6+6; int n,k; vector<int> v; int main(){ scanf("%d%d", &n, &k); n = pow(2, n); for (int i = 1; i <= n; ++i){ int x; scanf("%d", &x); v.push_back(x); } if (k % 2 == 1) reverse(v.begin(), v.end()); for (int i = 0; i < (int)v.size(); ++i) printf("%d ", v[i]); } |