#include <iostream> #include <cmath> #include <vector> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, t; cin >> n >> t; bool reverse = static_cast<bool>(t & 1); int g = pow(2, n); if (reverse) { vector<int> x(g); for (int& a : x) cin >> a; for (auto it = x.rbegin(); it != x.rend(); ++it) cout << *it << ' '; } else { int a; while (g--) { cin >> a; cout << a << ' '; } } return 0; }
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 26 27 28 29 30 31 32 33 34 | #include <iostream> #include <cmath> #include <vector> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, t; cin >> n >> t; bool reverse = static_cast<bool>(t & 1); int g = pow(2, n); if (reverse) { vector<int> x(g); for (int& a : x) cin >> a; for (auto it = x.rbegin(); it != x.rend(); ++it) cout << *it << ' '; } else { int a; while (g--) { cin >> a; cout << a << ' '; } } return 0; } |