3 5 .#... ..... .#..#
9 Let $(i,j)$ denote the cell at the $i$\-th row from the top and $j$\-th column from the left. If Takahashi starts at $(2,3)$, possible movements include: * $(2,3) \to (2,4) \to (1,4) \to (1,5) \to (2,5)$ * $(2,3) \to (2,4) \to (3,4)$ * $(2,3) \to (2,2)$ * $(2,3) \to (1,3)$ * $(2,3) \to (3,3)$ Thus, including the cells he passes through, he can reach at least nine cells from $(2,3)$. Actually, no other cells can be reached, so the degree of freedom for $(2,3)$ is $9$. This is the maximum degree of freedom among all cells without magnets, so print $9$.
3 3 ..# #.. ..#
1 For any cell without a magnet, there is a magnet in at least one of the adjacent cells. Thus, he cannot move from any of these cells, so their degrees of freedom are $1$. Therefore, print $1$.
{
"problem": {
"name": "Grid and Magnet",
"description": {
"content": "There is a grid of $H$ rows and $W$ columns. Some cells (possibly zero) contain magnets. The state of the grid is represented by $H$ strings $S_1, S_2, \\ldots, S_H$ of length $W$. If the $j$\\-th cha",
"description_type": "Markdown"
},
"platform": "AtCoder",
"limit": {
"time_limit": 2000,
"memory_limit": 262144
},
"difficulty": "None",
"is_remote": true,
"is_sync": true,
"sync_url": null,
"sign": "abc351_d"
},
"statements": [
{
"statement_type": "Markdown",
"content": "There is a grid of $H$ rows and $W$ columns. Some cells (possibly zero) contain magnets. \nThe state of the grid is represented by $H$ strings $S_1, S_2, \\ldots, S_H$ of length $W$. If the $j$\\-th cha...",
"is_translate": false,
"language": "English"
}
]
}