AtCoder Beginner Contest 197(Sponsored by Panasonic)
B
Visibility
AtCoder
⌀ 0
原题
← AC →
翻译中…

Problem Statement

翻译中…

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).

翻译中…

Constraints

翻译中…
  • $1 \le H \le 100$
  • $1 \le W \le 100$
  • $1 \le X \le H$
  • $1 \le Y \le W$
  • $S_i$ is a string of length $W$ consisting of . and #.
  • The square $(X, Y)$ does not contain an obstacle.
翻译中…

Input

翻译中…

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

翻译中…

Output

翻译中…

Print the answer.

翻译中…

样例

Input #1
4 4 2 2
##..
...#
#.#.
.#.#
Output #1
4
The squares visible from the square $(2, 2)$ are: - $(2, 1)$ - $(2, 2)$ - $(2, 3)$ - $(3, 2)$
Input #2
3 5 1 4
#....
#####
....#
Output #2
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.
Input #3
5 5 4 2
.#..#
#.###
##...
#..#.
#.###
Output #3
3
题目信息
题号
abc197_b
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。