#include <assert.h> #include <limits.h> #include <stdio.h> #include <time.h> #ifdef TS_TEST #define TS_TIMER_START(t) do { (t) = clock(); } while (0) #define TS_TIMER_SHOW(t, title) do {\ int msec = (clock() - (t)) * 1000 / CLOCKS_PER_SEC;\ fprintf(stderr, "%s: %d.%03d\n", (title), msec/1000, msec%1000);\ } while (0) #else #define TS_TIMER_START(t) #define TS_TIMER_SHOW(t, title) #endif #define N_MAX 20 #define T_MAX 1000000000 #define A_MAX 1000000000 #define M_MAX (2 << (N_MAX - 1)) int tab[M_MAX] = { 0 }; void load_tab(int m) { int i; for (i = 0; i < m; i++) { int a; scanf("%d", &a); tab[i] = a; } } void copy_numbers() { int c; while ((c = getc(stdin)) != '\n') { } while ((c = getc(stdin)) != EOF) { putc(c, stdout); } } void write_reverted(int m) { int i; printf("%d", tab[m-1]); for (i = m-2; 0 <= i; i--) { printf(" %d", tab[i]); } puts(""); } int main() { clock_t cl_total; TS_TIMER_START(cl_total); int n; int t; scanf("%d %d", &n, &t); int m = 2 << (n - 1); if (t % 2 == 0) { copy_numbers(); } else { load_tab(m); write_reverted(m); } TS_TIMER_SHOW(cl_total, "Total time"); }
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | #include <assert.h> #include <limits.h> #include <stdio.h> #include <time.h> #ifdef TS_TEST #define TS_TIMER_START(t) do { (t) = clock(); } while (0) #define TS_TIMER_SHOW(t, title) do {\ int msec = (clock() - (t)) * 1000 / CLOCKS_PER_SEC;\ fprintf(stderr, "%s: %d.%03d\n", (title), msec/1000, msec%1000);\ } while (0) #else #define TS_TIMER_START(t) #define TS_TIMER_SHOW(t, title) #endif #define N_MAX 20 #define T_MAX 1000000000 #define A_MAX 1000000000 #define M_MAX (2 << (N_MAX - 1)) int tab[M_MAX] = { 0 }; void load_tab(int m) { int i; for (i = 0; i < m; i++) { int a; scanf("%d", &a); tab[i] = a; } } void copy_numbers() { int c; while ((c = getc(stdin)) != '\n') { } while ((c = getc(stdin)) != EOF) { putc(c, stdout); } } void write_reverted(int m) { int i; printf("%d", tab[m-1]); for (i = m-2; 0 <= i; i--) { printf(" %d", tab[i]); } puts(""); } int main() { clock_t cl_total; TS_TIMER_START(cl_total); int n; int t; scanf("%d %d", &n, &t); int m = 2 << (n - 1); if (t % 2 == 0) { copy_numbers(); } else { load_tab(m); write_reverted(m); } TS_TIMER_SHOW(cl_total, "Total time"); } |