#abc300c. C - Cross

C - Cross

Score : 300300 points

问题描述

我们有一个由 HH 行和 WW 列组成的网格。我们用 (i,j)(i, j) 表示网格中从上数第 ii 行、从左数第 jj 列的单元格。
网格中的每个单元格上都有符号 #.。令 C[i][j]C[i][j] 表示在 (i,j)(i, j) 处所写的字符。对于至少满足以下条件之一的整数 iijj1iH1 \leq i \leq H 或者 1jW1 \leq j \leq W,我们定义 C[i][j]C[i][j].

如果满足以下所有条件,则称以 (a,b)(a, b) 为中心且包含 (a,b)(a, b)(a+d,b+d)(a+d,b+d)(a+d,bd)(a+d,b-d)(ad,b+d)(a-d,b+d)(ad,bd)(a-d,b-d)(4n+1)(4n+1) 个格子(其中 1dn1 \leq d \leq n1n1 \leq n)是一个 大小为 nn 的十字交叉点

  • C[a][b]C[a][b]#
  • 对于所有满足 1dn1 \leq d \leq n 的整数 ddC[a+d][b+d]C[a+d][b+d], C[a+d][bd]C[a+d][b-d], C[ad][b+d]C[a-d][b+d]C[ad][bd]C[a-d][b-d] 都是 #
  • 至少有一个 C[a+n+1][b+n+1]C[a+n+1][b+n+1], C[a+n+1][bn1]C[a+n+1][b-n-1], C[an1][b+n+1]C[a-n-1][b+n+1] 或者 C[an1][bn1]C[a-n-1][b-n-1].

例如,下图所示网格中有一个大小为 11 的十字交叉点,中心位于 (2,2)(2, 2),另一个大小为 22 的十字交叉点中心位于 (3,7)(3, 7)

网格中有一些十字交叉点。除了构成交叉点的格子外,其它格子上未写有 #
另外,两个不同交叉点所包含的方格之间不会共享一个角。下图所示的两个网格是两个不同交叉点所包含的方格共享一个角的例子;这样的网格不会作为输入给出。例如,左边的网格无效,因为 (3,3)(3, 3)(4,4)(4, 4) 共享了一个角。

N=min(H,W)N = \min(H, W),并令 SnS_n 表示大小为 nn 的十字交叉点的数量。求解 S1,S2,,SNS_1, S_2, \dots, S_N

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

We have a grid with HH horizontal rows and WW vertical columns. We denote by (i,j)(i, j) the cell at the ii-th row from the top and jj-th column from the left of the grid.
Each cell in the grid has a symbol # or . written on it. Let C[i][j]C[i][j] be the character written on (i,j)(i, j). For integers ii and jj such that at least one of 1iH1 \leq i \leq H and 1jW1 \leq j \leq W is violated, we define C[i][j]C[i][j] to be ..

(4n+1)(4n+1) squares, consisting of (a,b)(a, b) and (a+d,b+d),(a+d,bd),(ad,b+d),(ad,bd)(a+d,b+d),(a+d,b-d),(a-d,b+d),(a-d,b-d) (1dn,1n)(1 \leq d \leq n, 1 \leq n), are said to be a cross of size nn centered at (a,b)(a,b) if and only if all of the following conditions are satisfied:

  • C[a][b]C[a][b] is #.
  • C[a+d][b+d],C[a+d][bd],C[ad][b+d]C[a+d][b+d],C[a+d][b-d],C[a-d][b+d], and C[ad][bd]C[a-d][b-d] are all #, for all integers dd such that 1dn1 \leq d \leq n,
  • At least one of C[a+n+1][b+n+1],C[a+n+1][bn1],C[an1][b+n+1]C[a+n+1][b+n+1],C[a+n+1][b-n-1],C[a-n-1][b+n+1], and C[an1][bn1]C[a-n-1][b-n-1] is ..

For example, the grid in the following figure has a cross of size 11 centered at (2,2)(2, 2) and another of size 22 centered at (3,7)(3, 7).

image

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 (3,3)(3, 3) and (4,4)(4, 4) share a corner.

image2

Let N=min(H,W)N = \min(H, W), and SnS_n be the number of crosses of size nn. Find S1,S2,,SNS_1, S_2, \dots, S_N.

Constraints

  • 3H,W1003 \leq H, W \leq 100
  • C[i][j]C[i][j] is # or ..
  • No two different squares that comprise two different crosses share a corner.
  • HH and WW are integers.

Input

The input is given from Standard Input in the following format:

HH WW

C[1][1]C[1][2]C[1][W]C[1][1]C[1][2]\dots C[1][W]

C[2][1]C[2][2]C[2][W]C[2][1]C[2][2]\dots C[2][W]

\vdots

C[H][1]C[H][2]C[H][W]C[H][1]C[H][2]\dots C[H][W]

Output

Print S1,S2,S_1, S_2, \dots, and SNS_N, 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 11 centered at (2,2)(2, 2) and another of size 22 centered at (3,7)(3, 7).

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