#include using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { int n; cin >> n; vector a(n, vector(n)); vector dx = { 0, 1, 0, -1 }; vector dy = { 1, 0, -1, 0 }; int x = 0, y = 0, d = 0; rep(_, n * n) { a[x][y] = _ + 1; int nx = x + dx[d]; int ny = y + dy[d]; if (nx < 0 || nx >= n || ny < 0 || ny >= n || a[nx][ny]) { d = (d + 1) % 4; nx = x + dx[d]; ny = y + dy[d]; } x = nx, y = ny; } rep(i, n) rep(j, n) { printf("%03d%c", a[i][j], j == n - 1 ? '\n' : ' '); } return 0; }