#include using namespace std; using i64 = int64_t; using u64 = uint64_t; using vi64 = vector; using vu64 = vector; using vvi64 = vector; using vvu64 = vector; #define rep(i,n) for(int i=0, i##_len=(n); i> n; vvi64 m(n, vi64(n)); int x = 0, y = 0, d = 0; for (int i = 1; i <= n * n; i++) { m[y][x] = i; int xx = x + dy[d]; int yy = y + dy[d]; if (!(0 <= xx && xx < n && 0 <= yy && yy < n) || m[yy][xx] != 0) { d++; d %= 4; xx = x + dx[d]; yy = y + dy[d]; } x = xx; y = yy; } rep(y,n) { rep(x,n) { if (x + 1 < n) printf("%03d", m[y][x]); else printf("%03d\n", m[y][x]); } } return; } int main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); run(); return 0; }