#include <iostream> #include <vector> int main() { std::ios::sync_with_stdio(false); long n, t; std::cin >> n >> t; long tot_elem = 0x01 << n; std::vector<long> v(tot_elem); for(long i=0; i<tot_elem; ++i){ std::cin >> v[i]; } if(t%2 == 0){ //even number of shuffles for(long i=0; i<tot_elem; ++i){ std::cout<<v[i]<< " "; } } else{ for(long i=tot_elem-1; i>= 0; --i){ std::cout<<v[i]<< " "; } } std::cout<<std::endl; return 0; }
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 28 29 30 | #include <iostream> #include <vector> int main() { std::ios::sync_with_stdio(false); long n, t; std::cin >> n >> t; long tot_elem = 0x01 << n; std::vector<long> v(tot_elem); for(long i=0; i<tot_elem; ++i){ std::cin >> v[i]; } if(t%2 == 0){ //even number of shuffles for(long i=0; i<tot_elem; ++i){ std::cout<<v[i]<< " "; } } else{ for(long i=tot_elem-1; i>= 0; --i){ std::cout<<v[i]<< " "; } } std::cout<<std::endl; return 0; } |