#include <iostream> #include <cstdio> #include <vector> using namespace std; vector<int> a; int main() { int n,t; scanf("%d%d",&n,&t); int p=1; for(int i=0;i<n;i++) p*=2; a.resize(p); for (int i=0;i<p;i++) scanf("%d",&a[i]); if (t%2==0) for (int i=0;i<p;i++) printf("%d ",a[i]); else for (int i=p-1;i>=0;i--) printf("%d ",a[i]); 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 | #include <iostream> #include <cstdio> #include <vector> using namespace std; vector<int> a; int main() { int n,t; scanf("%d%d",&n,&t); int p=1; for(int i=0;i<n;i++) p*=2; a.resize(p); for (int i=0;i<p;i++) scanf("%d",&a[i]); if (t%2==0) for (int i=0;i<p;i++) printf("%d ",a[i]); else for (int i=p-1;i>=0;i--) printf("%d ",a[i]); return 0; } |