#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
int arr[(const int)1<<20];
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n, t;
cin>>n>>t;
int k=1<<n;
for(int i=0;i<k;i++){
cin>>arr[i];
}
t=t%2;
if(t) for(int i=k-1;i>=0;i--)
cout<<arr[i]<<" ";
else for(int i=0;i<k;i++)
cout<<arr[i]<<" ";
return 0;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #include <bits/stdc++.h> #define endl "\n" using namespace std; int arr[(const int)1<<20]; int main(){ ios::sync_with_stdio(0); cin.tie(0); int n, t; cin>>n>>t; int k=1<<n; for(int i=0;i<k;i++){ cin>>arr[i]; } t=t%2; if(t) for(int i=k-1;i>=0;i--) cout<<arr[i]<<" "; else for(int i=0;i<k;i++) cout<<arr[i]<<" "; return 0; } |
English