#include <cstdio> #include <vector> #include <map> #include <set> #include <queue> #include <algorithm> #include <string> #include <sstream> #include <cmath> using namespace std; typedef vector<int> vi; typedef long long ll; typedef vector<ll> vll; typedef pair<int,int> pii; #define mp make_pair #define REP(i,n) for (int i=0,___=(n); i<___; ++i) #define FOR(i,a,b) for (int i=(a),___=(b); i<=___; ++i) #define FORD(i,a,b) for (int i=(a),___=(b); i>=___; --i) int read() { int n; scanf("%d", &n); return n; } ll readl() { ll n; scanf("%lld", &n); return n; } int main() { int n = 1 << read(); int t = read(); vector<int> v(n); REP(i, n) v[i] = read(); if (t % 2 == 1) reverse(v.begin(), v.end()); REP(i, n) printf("%d ", v[i]); printf("\n"); 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 | #include <cstdio> #include <vector> #include <map> #include <set> #include <queue> #include <algorithm> #include <string> #include <sstream> #include <cmath> using namespace std; typedef vector<int> vi; typedef long long ll; typedef vector<ll> vll; typedef pair<int,int> pii; #define mp make_pair #define REP(i,n) for (int i=0,___=(n); i<___; ++i) #define FOR(i,a,b) for (int i=(a),___=(b); i<=___; ++i) #define FORD(i,a,b) for (int i=(a),___=(b); i>=___; --i) int read() { int n; scanf("%d", &n); return n; } ll readl() { ll n; scanf("%lld", &n); return n; } int main() { int n = 1 << read(); int t = read(); vector<int> v(n); REP(i, n) v[i] = read(); if (t % 2 == 1) reverse(v.begin(), v.end()); REP(i, n) printf("%d ", v[i]); printf("\n"); return 0; } |