#include <iostream>
using namespace std;
int main() {
// your code goes here
//cout <<(1<<10);
ios_base::sync_with_stdio(0);
int n,t,p;
cin>>n>>t;
p=(1<<n);
int *tab=new int[p];
for(int i=0;i<p;i++)
cin >>tab[i];
if (t%2>0)
for (int i=0;i<p/2;i++)
swap(tab[i],tab[p-1-i]);
for (int i=0;i<p;i++) cout<<tab[i]<<" ";
return 0;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #include <iostream> using namespace std; int main() { // your code goes here //cout <<(1<<10); ios_base::sync_with_stdio(0); int n,t,p; cin>>n>>t; p=(1<<n); int *tab=new int[p]; for(int i=0;i<p;i++) cin >>tab[i]; if (t%2>0) for (int i=0;i<p/2;i++) swap(tab[i],tab[p-1-i]); for (int i=0;i<p;i++) cout<<tab[i]<<" "; return 0; } |
English