#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); int n, t; cin >> n >> t; vector<int> v(1 << n); for (int i = 0; i < (1 << n); i++) { cin >> v[i]; } if (t % 2 == 1) { reverse(v.begin(), v.end()); } for (int 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 21 22 23 24 25 | #include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); int n, t; cin >> n >> t; vector<int> v(1 << n); for (int i = 0; i < (1 << n); i++) { cin >> v[i]; } if (t % 2 == 1) { reverse(v.begin(), v.end()); } for (int x: v) { cout << x << ' '; } cout << endl; } |