#include "bits/stdc++.h"
using namespace std;
int n,c,x=1;
vector <int> t;
int main()
{
cin>>n>>c;
while(n--)
x=x<<1;
// cout<<x;
t.resize(x+1);
for(int g=1;g<=x;g++)
cin>>t[g];
if((c&1)==0)
for(int g=1;g<=x;g++)
cout<<t[g]<<" ";
else
for(int g=x;g>0;g--)
cout<<t[g]<<" ";
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #include "bits/stdc++.h" using namespace std; int n,c,x=1; vector <int> t; int main() { cin>>n>>c; while(n--) x=x<<1; // cout<<x; t.resize(x+1); for(int g=1;g<=x;g++) cin>>t[g]; if((c&1)==0) for(int g=1;g<=x;g++) cout<<t[g]<<" "; else for(int g=x;g>0;g--) cout<<t[g]<<" "; } |
English