#include <bits/stdc++.h> using namespace std; int n, t; vector<int> v; int main() { cin >> n >> t; v.resize(1<<n); for (int i = 0; i < (1<<n); i++) cin >> v[i]; if (t%2) { reverse(begin(v), end(v)); } for (auto x: v) { cout << x << " "; } cout << endl; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #include <bits/stdc++.h> using namespace std; int n, t; vector<int> v; int main() { cin >> n >> t; v.resize(1<<n); for (int i = 0; i < (1<<n); i++) cin >> v[i]; if (t%2) { reverse(begin(v), end(v)); } for (auto x: v) { cout << x << " "; } cout << endl; } |