100 atcoder#ABC197B. [ABC197B] Visibility
[ABC197B] Visibility
Score : points
Problem Statement
We have a grid of horizontal rows and vertical columns, where some of the squares contain obstacles.
Let denote the square at the -th row from the top and -th column from the left.
You are given strings . The -th character of describes the square ; #
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 (including itself).
Constraints
- is a string of length consisting of
.
and#
. - The square does not contain an obstacle.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
4 4 2 2
##..
...#
#.#.
.#.#
4
The squares visible from the square 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