#include <cstdio> #include <vector> void solve(int n, int k, std::vector<int> &arr) { int shifter = 0; if(k % 2) { shifter = arr.size() - 1; } for(int i = 0; i < arr.size(); ++i) { printf("%d ", arr[i ^ shifter]); } printf("\n"); } int main() { int n, t, x; scanf("%d %d", &n, &t); std::vector<int> arr; for(int i = 0; i < 2 << (n - 1); ++i) { scanf("%d", &x); arr.push_back(x); } solve(n, t, arr); 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 | #include <cstdio> #include <vector> void solve(int n, int k, std::vector<int> &arr) { int shifter = 0; if(k % 2) { shifter = arr.size() - 1; } for(int i = 0; i < arr.size(); ++i) { printf("%d ", arr[i ^ shifter]); } printf("\n"); } int main() { int n, t, x; scanf("%d %d", &n, &t); std::vector<int> arr; for(int i = 0; i < 2 << (n - 1); ++i) { scanf("%d", &x); arr.push_back(x); } solve(n, t, arr); return 0; } |