#include <iostream> #include <algorithm> using namespace std; int main() { ios_base::sync_with_stdio( false ); cin.tie( nullptr ); int n, t; cin >> n >> t; n = (1<<n); int *a = new int[n]; for( int i = 0; i < n; ++i ) cin >> a[i]; if( t % 2 ) reverse( a, a+n ); for( int i = 0; i < n; ++i ) cout << a[i] << " "; return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #include <iostream> #include <algorithm> using namespace std; int main() { ios_base::sync_with_stdio( false ); cin.tie( nullptr ); int n, t; cin >> n >> t; n = (1<<n); int *a = new int[n]; for( int i = 0; i < n; ++i ) cin >> a[i]; if( t % 2 ) reverse( a, a+n ); for( int i = 0; i < n; ++i ) cout << a[i] << " "; return 0; } |