atcoder#ABC300C. [ABC300C] Cross
[ABC300C] Cross
Score : points
Problem Statement
We have a grid with horizontal rows and vertical columns. We denote by the cell at the -th row from the top and -th column from the left of the grid.
Each cell in the grid has a symbol #
or .
written on it. Let be the character written on . For integers and such that at least one of and is violated, we define to be .
.
squares, consisting of and , are said to be a cross of size n centered at (a,b) if and only if all of the following conditions are satisfied:
- is
#
. - , and are all
#
, for all integers such that , - At least one of , and is
.
.
For example, the grid in the following figure has a cross of size centered at and another of size centered at .
The grid has some crosses. No #
is written on the cells except for those comprising a cross.
Additionally, no two squares that comprise two different crosses share a corner. The two grids in the following figure are the examples of grids where two squares that comprise different crosses share a corner; such grids are not given as an input. For example, the left grid is invalid because and share a corner.
Let , and be the number of crosses of size . Find .
Constraints
- is
#
or.
. - No two different squares that comprise two different crosses share a corner.
- and are integers.
Input
The input is given from Standard Input in the following format:
Output
Print , and , separated by spaces.
5 9
#.#.#...#
.#...#.#.
#.#...#..
.....#.#.
....#...#
1 1 0 0 0
As described in the Problem Statement, there are a cross of size centered at and another of size centered at .
3 3
...
...
...
0 0 0
There may be no cross.
3 16
#.#.....#.#..#.#
.#.......#....#.
#.#.....#.#..#.#
3 0 0
15 20
#.#..#.............#
.#....#....#.#....#.
#.#....#....#....#..
........#..#.#..#...
#.....#..#.....#....
.#...#....#...#..#.#
..#.#......#.#....#.
...#........#....#.#
..#.#......#.#......
.#...#....#...#.....
#.....#..#.....#....
........#.......#...
#.#....#....#.#..#..
.#....#......#....#.
#.#..#......#.#....#
5 0 1 0 0 0 1 0 0 0 0 0 0 0 0