#include<iostream> #include<cstdio> #include<algorithm> #include<vector> #include<cmath> using namespace std; int main() { vector<int> vec; int n, t; scanf("%d%d", &n, &t); int num = 2; for(int i = 1; i < n; i++) num *= 2; int number; for(int i = 0; i < num; i++) { scanf("%d", &number); vec.push_back(number); } if(t&1) reverse(vec.begin(), vec.end()); for(int i = 0; i < num; i++) { printf("%d ", vec[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 28 29 | #include<iostream> #include<cstdio> #include<algorithm> #include<vector> #include<cmath> using namespace std; int main() { vector<int> vec; int n, t; scanf("%d%d", &n, &t); int num = 2; for(int i = 1; i < n; i++) num *= 2; int number; for(int i = 0; i < num; i++) { scanf("%d", &number); vec.push_back(number); } if(t&1) reverse(vec.begin(), vec.end()); for(int i = 0; i < num; i++) { printf("%d ", vec[i]); } } |