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