#abc300c. C - Cross
C - Cross
Score : points
问题描述
我们有一个由 行和 列组成的网格。我们用 表示网格中从上数第 行、从左数第 列的单元格。
网格中的每个单元格上都有符号 #
或 .
。令 表示在 处所写的字符。对于至少满足以下条件之一的整数 和 : 或者 ,我们定义 为 .
。
如果满足以下所有条件,则称以 为中心且包含 、、、 和 这 个格子(其中 ,)是一个 大小为 的十字交叉点:
- 是
#
。 - 对于所有满足 的整数 ,, , 和 都是
#
。 - 至少有一个 , , 或者 是
.
。
例如,下图所示网格中有一个大小为 的十字交叉点,中心位于 ,另一个大小为 的十字交叉点中心位于 。
网格中有一些十字交叉点。除了构成交叉点的格子外,其它格子上未写有 #
。
另外,两个不同交叉点所包含的方格之间不会共享一个角。下图所示的两个网格是两个不同交叉点所包含的方格共享一个角的例子;这样的网格不会作为输入给出。例如,左边的网格无效,因为 和 共享了一个角。
令 ,并令 表示大小为 的十字交叉点的数量。求解 。
以上为通义千问 qwen-max 翻译,仅供参考。
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 centered at 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.
Sample Input 1
5 9
#.#.#...#
.#...#.#.
#.#...#..
.....#.#.
....#...#
Sample Output 1
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 .
Sample Input 2
3 3
...
...
...
Sample Output 2
0 0 0
There may be no cross.
Sample Input 3
3 16
#.#.....#.#..#.#
.#.......#....#.
#.#.....#.#..#.#
Sample Output 3
3 0 0
Sample Input 4
15 20
#.#..#.............#
.#....#....#.#....#.
#.#....#....#....#..
........#..#.#..#...
#.....#..#.....#....
.#...#....#...#..#.#
..#.#......#.#....#.
...#........#....#.#
..#.#......#.#......
.#...#....#...#.....
#.....#..#.....#....
........#.......#...
#.#....#....#.#..#..
.#....#......#....#.
#.#..#......#.#....#
Sample Output 4
5 0 1 0 0 0 1 0 0 0 0 0 0 0 0
update @ 2024/3/10 08:24:10