{"problem":{"name":"146. Gold Miner","description":{"content":"You're standing in a large 2D grid. The grid consists of several gold blocks. The gold is highly sought after , so for each position in the grid you want to calculate how many steps it would take to w","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":1000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF10269146"},"statements":[{"statement_type":"Markdown","content":"You're standing in a large 2D grid. The grid consists of several gold blocks. The gold is highly sought after , so for each position in the grid you want to calculate how many steps it would take to walk to the nearest gold block. You can walk left, right, up, or down, but not diagonally.\n\nThe first line of input contains a single integer $n$: the size of the *square* grid.\n\nThe next $n$ lines each contain $n$ characters, representing the status of each position in the grid. If the position contains a gold block, it will be represented with an \"X\". If the position doesn't contain a gold block, it will be represented with a single dot \".\".\n\nOutput $n$ lines: the board, after making a few modifications:\n\nPositions with gold blocks should remain an \"X\".\n\nPositions without gold blocks that are *under 10 blocks away* from the nearest gold block in walking distance should be represented by their walking distance to the nearest gold block.\n\nOtherwise, positions without gold blocks that are at least 10 blocks away from the nearest gold block in walking distance should remain a single dot \".\".\n\n## Input\n\nThe first line of input contains a single integer $n$: the size of the *square* grid.The next $n$ lines each contain $n$ characters, representing the status of each position in the grid. If the position contains a gold block, it will be represented with an \"X\". If the position doesn't contain a gold block, it will be represented with a single dot \".\".\n\n## Output\n\nOutput $n$ lines: the board, after making a few modifications:Positions with gold blocks should remain an \"X\".Positions without gold blocks that are *under 10 blocks away* from the nearest gold block in walking distance should be represented by their walking distance to the nearest gold block.Otherwise, positions without gold blocks that are at least 10 blocks away from the nearest gold block in walking distance should remain a single dot \".\".\n\n[samples]","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ n \\in \\mathbb{Z}^+ $ be the side length of a square grid.  \nLet $ G \\subseteq \\{1, \\dots, n\\} \\times \\{1, \\dots, n\\} $ be the set of positions containing gold blocks (marked \"X\").  \nLet $ d((i,j), (k,l)) = |i - k| + |j - l| $ be the Manhattan distance between two grid positions.  \n\n**Constraints**  \n- $ 1 \\leq n \\leq 100 $ (implied by problem context).  \n- Each grid cell is either \"X\" (gold) or \".\" (empty).  \n\n**Objective**  \nFor each position $ (i,j) \\in \\{1, \\dots, n\\} \\times \\{1, \\dots, n\\} $:  \n- If $ (i,j) \\in G $, output \"X\".  \n- Else, compute $ d_{\\min}(i,j) = \\min_{(k,l) \\in G} d((i,j), (k,l)) $.  \n  - If $ d_{\\min}(i,j) < 10 $, output $ d_{\\min}(i,j) $ (as a digit character).  \n  - If $ d_{\\min}(i,j) \\geq 10 $, output \".\".","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF10269146","tags":[],"sample_group":[],"created_at":"2026-03-03 11:00:39"}}