#include<string> #include<stdio.h> #include<iostream> #include<set> #include<vector> #include<algorithm> #include<queue> #include<bitset> #define ll long long #define pb push_back #define sc scanf #define pr printf #define f first #define s second #define mp make_pair #define lb lower_bound using namespace std; int t[2000000]; int main (){ int n,ta; scanf("%d%d",&n,&ta); n=(1<<n)-1; for(int i=0;i<=n;i++){ sc("%d",&t[i]); } if((ta&1)==0)for(int i=0;i<=n;i++)pr("%d ",t[i]); else for(int i=n;i>=0;i--)pr("%d ",t[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 24 25 26 27 28 29 30 31 32 | #include<string> #include<stdio.h> #include<iostream> #include<set> #include<vector> #include<algorithm> #include<queue> #include<bitset> #define ll long long #define pb push_back #define sc scanf #define pr printf #define f first #define s second #define mp make_pair #define lb lower_bound using namespace std; int t[2000000]; int main (){ int n,ta; scanf("%d%d",&n,&ta); n=(1<<n)-1; for(int i=0;i<=n;i++){ sc("%d",&t[i]); } if((ta&1)==0)for(int i=0;i<=n;i++)pr("%d ",t[i]); else for(int i=n;i>=0;i--)pr("%d ",t[i]); return 0; } |