/* -*- coding: utf-8 -*- * * 2212.cc: No.2212 One XOR Matrix - yukicoder */ #include #include using namespace std; /* constant */ const int MAX_N = 10; const int NBITS = 1 << MAX_N; const int M = 4; const int MMSK = (1 << M) - 1; const int bs[M][M] = { { 7, 14, 0, 8}, { 4, 12, 2, 11}, {15, 9, 6, 1}, {13, 10, 5, 3}, }; /* typedef */ /* global variables */ int as[NBITS][NBITS], cs[M][M]; /* subroutines */ void check(int n) { int nbits = 1 << n; bool used[NBITS * NBITS]; fill(used, used + nbits * nbits, false); for (int i = 0; i < nbits; i++) { int x = 0; for (int j = 0; j < nbits; j++) x ^= as[i][j], used[as[i][j]] = true; printf(" %d", x); } putchar('\n'); for (int j = 0; j < nbits; j++) { int x = 0; for (int i = 0; i < nbits; i++) x ^= as[i][j]; printf(" %d", x); } putchar('\n'); bool ok = true; for (int i = 0; ok && i < nbits * nbits; i++) ok = used[i]; if (ok) puts("OK"); else puts("NG"); } /* main */ int main() { int n; scanf("%d", &n); if (n <= 1) { puts("-1"); return 0; } int nbits = 1 << n; for (int i = 0, x = 0; i < nbits; i++) for (int j = 0; j < nbits; j++, x++) as[i][j] = x; //check(n); for (int i0 = 0; i0 < nbits; i0 += M) { for (int i = 0, x = 0; i < M; i++) for (int j = 0; j < M; j++, x++) { int i1 = bs[i][j] / M, j1 = bs[i][j] % M; cs[i][j] = as[i0 + i1][i0 + j1]; } for (int i = 0, x = 0; i < M; i++) for (int j = 0; j < M; j++, x++) as[i0 + i][i0 + j] = cs[i][j]; } //check(n); for (int i = 0, x = 0; i < nbits; i++) for (int j = 0; j < nbits; j++, x++) printf("%d%c", as[i][j], (j + 1 < nbits) ? ' ' : '\n'); return 0; }