#include<bits/stdc++.h> using namespace std; int n, t; int talia[1231231]; void load() { cin >> n >> t; for(int i = 0; i < (1 << n); ++i) cin >> talia[i]; } void shuffle() { if(t & 1) { int i, j; for(i = 0, j = (1 << n) - 1; i < j; ++i, --j) swap(talia[i], talia[j]); } } void out() { for(int i = 0; i < (1 << n); ++i) cout << talia[i] << " "; cout << endl; } int main() { ios_base::sync_with_stdio(0); load(); shuffle(); out(); }
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 | #include<bits/stdc++.h> using namespace std; int n, t; int talia[1231231]; void load() { cin >> n >> t; for(int i = 0; i < (1 << n); ++i) cin >> talia[i]; } void shuffle() { if(t & 1) { int i, j; for(i = 0, j = (1 << n) - 1; i < j; ++i, --j) swap(talia[i], talia[j]); } } void out() { for(int i = 0; i < (1 << n); ++i) cout << talia[i] << " "; cout << endl; } int main() { ios_base::sync_with_stdio(0); load(); shuffle(); out(); } |