/* -*- 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]; /* subroutines */ void check(int n) { int nbits = 1 << n; for (int i = 0; i < nbits; i++) { int x = 0; for (int j = 0; j < nbits; j++) x ^= as[i][j]; 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'); } /* 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; i < M; i++) for (int j = 0; j < M; j++) as[i0 + i][i0 + j] = (as[i0 + i][i0 + j] & ~MMSK) | bs[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; }