#include <iostream> #include <vector> #include <math.h> using namespace std; int main() { ios::sync_with_stdio(false); vector <long long> tab; long long n, t, h; cin>>n>>t; unsigned long long ile = pow(2,n); for(unsigned long long i=0; i<ile; i++) { cin>>h; tab.push_back(h); } if(t%2==0) //normalna kolejnosc { for( long long i=0; i<ile; i++) cout<<tab[i]<<" "; } else if(t%2!=0) //kolejnosc odwrotna { for( long long i=ile-1; i>=0; i--) cout<<tab[i]<<" "; } }
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 | #include <iostream> #include <vector> #include <math.h> using namespace std; int main() { ios::sync_with_stdio(false); vector <long long> tab; long long n, t, h; cin>>n>>t; unsigned long long ile = pow(2,n); for(unsigned long long i=0; i<ile; i++) { cin>>h; tab.push_back(h); } if(t%2==0) //normalna kolejnosc { for( long long i=0; i<ile; i++) cout<<tab[i]<<" "; } else if(t%2!=0) //kolejnosc odwrotna { for( long long i=ile-1; i>=0; i--) cout<<tab[i]<<" "; } } |