//Karol Kaszuba #include <bits/stdc++.h> using namespace std; typedef long long LL; typedef vector<int> VI; typedef pair<int, int> PII; typedef double D; typedef long double LD; typedef vector<PII> VII; typedef unordered_set<int> USI; typedef unordered_set<LL> USLL; #define FOR(i,x,y) for(auto i=(x);i<=(y);++i) #define REP(i,x) FOR(i,0,(x)-1) #define FORD(i,x,y) for(auto i=(x);i>=(y);--i) #define VAR(i,c) __typeof(c) i=(c) #define FORE(i,c) for(VAR(i,(c).begin());i!=(c).end();++i) #define SIZE(c) (int)((c).size()) #define ALL(c) (c).begin(),(c).end() #define PB push_back #define EB emplace_back #define IN insert #define ER erase #define MP make_pair #define ST first #define ND second #define IOSYNC ios_base::sync_with_stdio(0) #define FREOPEN(f) freopen(f, "r", stdin),freopen(f, "w", stdout) int main() { IOSYNC; int k, t; cin >> k >> t; int n = 1 << k; VI v(n); REP(i, n) cin >> v[i]; if (t % 2) FORD(i, n - 1, 0) cout << v[i] << " "; else REP(i, n) cout << v[i] << " "; cout << "\n"; 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 35 36 37 38 39 40 41 42 43 44 45 46 | //Karol Kaszuba #include <bits/stdc++.h> using namespace std; typedef long long LL; typedef vector<int> VI; typedef pair<int, int> PII; typedef double D; typedef long double LD; typedef vector<PII> VII; typedef unordered_set<int> USI; typedef unordered_set<LL> USLL; #define FOR(i,x,y) for(auto i=(x);i<=(y);++i) #define REP(i,x) FOR(i,0,(x)-1) #define FORD(i,x,y) for(auto i=(x);i>=(y);--i) #define VAR(i,c) __typeof(c) i=(c) #define FORE(i,c) for(VAR(i,(c).begin());i!=(c).end();++i) #define SIZE(c) (int)((c).size()) #define ALL(c) (c).begin(),(c).end() #define PB push_back #define EB emplace_back #define IN insert #define ER erase #define MP make_pair #define ST first #define ND second #define IOSYNC ios_base::sync_with_stdio(0) #define FREOPEN(f) freopen(f, "r", stdin),freopen(f, "w", stdout) int main() { IOSYNC; int k, t; cin >> k >> t; int n = 1 << k; VI v(n); REP(i, n) cin >> v[i]; if (t % 2) FORD(i, n - 1, 0) cout << v[i] << " "; else REP(i, n) cout << v[i] << " "; cout << "\n"; return 0; } |