#include<cstdio> #include<vector> #include<cmath> void tasuj(std::vector<int> w){ if (w.size() == 1) std::printf("%d", w[0]); else{ std::size_t const half_size = w.size() / 2; std::vector<int> split_lo(w.begin(), w.begin() + half_size); std::vector<int> split_hi(w.begin() + half_size, w.end()); tasuj(split_hi); std::printf(" "); tasuj(split_lo); } } int main(){ int n,t,k; std::scanf("%d%d", &n, &t); int N = pow(2, n); t = t % 2; std::vector<int> talia; for( int i = 0; i < N; i++){ std::scanf("%d", &k); talia.push_back(k); } if( t % 2 == 0) for(int i = 0; i < N; i++){ std::printf("%d", talia[i]); } else tasuj(talia); 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 31 32 33 34 35 36 37 38 39 40 | #include<cstdio> #include<vector> #include<cmath> void tasuj(std::vector<int> w){ if (w.size() == 1) std::printf("%d", w[0]); else{ std::size_t const half_size = w.size() / 2; std::vector<int> split_lo(w.begin(), w.begin() + half_size); std::vector<int> split_hi(w.begin() + half_size, w.end()); tasuj(split_hi); std::printf(" "); tasuj(split_lo); } } int main(){ int n,t,k; std::scanf("%d%d", &n, &t); int N = pow(2, n); t = t % 2; std::vector<int> talia; for( int i = 0; i < N; i++){ std::scanf("%d", &k); talia.push_back(k); } if( t % 2 == 0) for(int i = 0; i < N; i++){ std::printf("%d", talia[i]); } else tasuj(talia); return 0; } |