/* -*- coding: utf-8 -*- * * 3730.cc: No.3730 Jagged Minesweeper - yukicoder */ #include #include #include using namespace std; /* constant */ const int MAX_N = 1000; const int MAX_NN = MAX_N * MAX_N; const int dxs[] = {1, 1, 0, -1, -1, -1, 0, 1}; const int dys[] = {0, -1, -1, -1, 0, 1, 1, 1}; /* typedef */ using qi = queue; /* global variables */ char s[MAX_N + 4]; int as[MAX_NN], cs[MAX_NN]; bool fs[MAX_NN]; /* subroutines */ /* main */ int main() { int n; scanf("%d", &n); for (int i = 0, u = 0; i < n; i++) { scanf("%s", s); for (int j = 0; j < n; j++) as[u++] = s[j] - '0'; } int nn = n * n; qi q; for (int u = 0; u < nn; u++) q.push(u); while (! q.empty()) { int u = q.front(); q.pop(); int dc = 0; if (! fs[u] && cs[u] < as[u]) fs[u] = true, dc = 1; else if (fs[u] && cs[u] >= as[u]) fs[u] = false, dc = -1; if (dc != 0) { int uy = u / n, ux = u % n; for (int di = 0; di < 8; di++) { int vy = uy + dys[di], vx = ux + dxs[di], v = vy * n + vx; if (vy >= 0 && vy < n && vx >= 0 && vx < n) { cs[v] += dc; q.push(v); } } } } for (int i = 0, u = 0; i < n; i++) { for (int j = 0; j < n; j++, u++) putchar(fs[u] ? 'o' : '.'); putchar('\n'); } return 0; }