#include <cstdio> #include <iostream> #include <vector> #include <list> #include <string> #include <set> #include <map> #include <algorithm> #include <utility> #include <cmath> #include <queue> #include <stack> #include <cassert> #include <cstring> #include <climits> #include <functional> #include <unordered_set> #include <unordered_map> #define VAR(i,v) __typeof(v) i = (v) #define SIZE(x) ((int)(x).size()) #define ALL(x) (x).begin(), (x).end() #define REP(i,b) for(int i=0; i<(b); ++i) #define FOR(i,a,b) for(int i=(a); i<=(b); ++i) #define FORD(i,a,b) for(int i=(a); i>=(b); --i) #define FOREACH(i,c) for(VAR(i,(c).begin()); i != (c).end(); ++i) #define PB push_back #define MP make_pair #define ST first #define ND second #define NL printf("\n") using namespace std; typedef pair<int,int> PII; typedef vector<int> VI; typedef long long LL; int main() { int n, t; scanf("%d %d", &n, &t); int k = 1<<n; VI q(k); for(int &x: q) scanf("%d", &x); t %= 2; REP(i,t) reverse(ALL(q)); for(int x: q) printf("%d ", x); NL; 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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | #include <cstdio> #include <iostream> #include <vector> #include <list> #include <string> #include <set> #include <map> #include <algorithm> #include <utility> #include <cmath> #include <queue> #include <stack> #include <cassert> #include <cstring> #include <climits> #include <functional> #include <unordered_set> #include <unordered_map> #define VAR(i,v) __typeof(v) i = (v) #define SIZE(x) ((int)(x).size()) #define ALL(x) (x).begin(), (x).end() #define REP(i,b) for(int i=0; i<(b); ++i) #define FOR(i,a,b) for(int i=(a); i<=(b); ++i) #define FORD(i,a,b) for(int i=(a); i>=(b); --i) #define FOREACH(i,c) for(VAR(i,(c).begin()); i != (c).end(); ++i) #define PB push_back #define MP make_pair #define ST first #define ND second #define NL printf("\n") using namespace std; typedef pair<int,int> PII; typedef vector<int> VI; typedef long long LL; int main() { int n, t; scanf("%d %d", &n, &t); int k = 1<<n; VI q(k); for(int &x: q) scanf("%d", &x); t %= 2; REP(i,t) reverse(ALL(q)); for(int x: q) printf("%d ", x); NL; return 0; } |