Score : $200$ points
We have a grid of $H$ horizontal rows and $W$ vertical columns, where some of the squares contain obstacles.
Let $(i, j)$ denote the square at the $i$-th row from the top and $j$-th column from the left.
You are given $H$ strings $S_1, S_2, S_3, \dots, S_H$. The $j$-th character of $S_i$ describes the square $(i, j)$; #
means the square contains an obstacle, and .
means it does not.
We say a square is visible from another when it is on the same row or the same column, and there is no obstacle between them (including themselves).
Print the number of squares visible from the square $(X, Y)$ (including $(X, Y)$ itself).
.
and #
.Input is given from Standard Input in the following format:
$H$ $W$ $X$ $Y$ $S_1$ $S_2$ $S_3$ $\hspace{3pt} \vdots$ $S_H$
Print the answer.
4 4 2 2 ##.. ...# #.#. .#.#
4
The squares visible from the square $(2, 2)$ are:
3 5 1 4 #.... ##### ....#
4
Even if two squares are on the same row or the same column, they are not visible from each other when there are obstacles between them.
5 5 4 2 .#..# #.### ##... #..#. #.###
3