#include <bits/stdc++.h> using namespace std; #define PB push_back #define FORE(i, t) for(__typeof(t.begin())i=t.begin();i!=t.end();++i) #define SZ(x) int((x).size()) #define REP(i, n) for(int i=0,_=(n);i<_;++i) #define FOR(i, a, b) for(int i=(a),_=(b);i<=_;++i) #define FORD(i, a, b) for(int i=(a),_=(b);i>=_;--i) typedef long long ll; typedef vector<int> vi; typedef pair<int, int> pii; const int INF = 1e9 + 9; void inline one() { int n, t; cin >> n >> t; int v[1 << n]; REP (i, 1 << n) { cin >> v[i]; } if (t % 2 != 0) { reverse(v, v + (1 << n)); } REP (i, 1 << n) { cout << v[i] << " "; } cout << "\n"; } int main() { ios::sync_with_stdio(false); //int z; cin >> z; while(z--) one(); }
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 35 36 37 38 | #include <bits/stdc++.h> using namespace std; #define PB push_back #define FORE(i, t) for(__typeof(t.begin())i=t.begin();i!=t.end();++i) #define SZ(x) int((x).size()) #define REP(i, n) for(int i=0,_=(n);i<_;++i) #define FOR(i, a, b) for(int i=(a),_=(b);i<=_;++i) #define FORD(i, a, b) for(int i=(a),_=(b);i>=_;--i) typedef long long ll; typedef vector<int> vi; typedef pair<int, int> pii; const int INF = 1e9 + 9; void inline one() { int n, t; cin >> n >> t; int v[1 << n]; REP (i, 1 << n) { cin >> v[i]; } if (t % 2 != 0) { reverse(v, v + (1 << n)); } REP (i, 1 << n) { cout << v[i] << " "; } cout << "\n"; } int main() { ios::sync_with_stdio(false); //int z; cin >> z; while(z--) one(); } |