#abc274b. B - Line Sensor

B - Line Sensor

Score : 200200 points

问题描述

存在一个从上到下有 HH 行、从左到右有 WW 列的网格。令 (i,j)(i, j) 表示从顶部数起第 ii 行、从左边数起第 jj 列的方格。

方格用字符 Ci,jC_{i,j} 描述。若 Ci,jC_{i,j}.,表示 (i,j)(i, j) 为空;若为 #,则表示 (i,j)(i, j) 包含一个箱子。

对于满足 1jW1 \leq j \leq W 的整数 jj,定义整数 XjX_j 如下:

  • XjX_j 是第 jj 列中箱子的数量。换句话说,XjX_j 是满足 Ci,jC_{i,j}# 的整数 ii 的个数。

找出所有的 X1,X2,,XWX_1, X_2, \dots, X_W

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

Problem Statement

There is a grid with HH rows from top to bottom and WW columns from left to right. Let (i,j)(i, j) denote the square at the ii-th row from the top and jj-th column from the left.
The squares are described by characters Ci,jC_{i,j}. If Ci,jC_{i,j} is ., (i,j)(i, j) is empty; if it is #, (i,j)(i, j) contains a box.

For integers jj satisfying 1jW1 \leq j \leq W, let the integer XjX_j defined as follows.

  • XjX_j is the number of boxes in the jj-th column. In other words, XjX_j is the number of integers ii such that Ci,jC_{i,j} is #.

Find all of X1,X2,,XWX_1, X_2, \dots, X_W.

Constraints

  • 1H10001 \leq H \leq 1000
  • 1W10001 \leq W \leq 1000
  • HH and WW are integers.
  • Ci,jC_{i, j} is . or #.

Input

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

HH WW

C1,1C1,2C1,WC_{1,1}C_{1,2}\dots C_{1,W}

C2,1C2,2C2,WC_{2,1}C_{2,2}\dots C_{2,W}

\vdots

CH,1CH,2CH,WC_{H,1}C_{H,2}\dots C_{H,W}

Output

Print X1,X2,,XWX_1, X_2, \dots, X_W in the following format:

X1X_1 X2X_2 \dots XWX_W

Sample Input 1

3 4
#..#
.#.#
.#.#

Sample Output 1

1 2 0 3

In the 11-st column, one square, (1,1)(1, 1), contains a box. Thus, X1=1X_1 = 1.
In the 22-nd column, two squares, (2,2)(2, 2) and (3,2)(3, 2), contain a box. Thus, X2=2X_2 = 2.
In the 33-rd column, no squares contain a box. Thus, X3=0X_3 = 0.
In the 44-th column, three squares, (1,4)(1, 4), (2,4)(2, 4), and (3,4)(3, 4), contain a box. Thus, X4=3X_4 = 3.
Therefore, the answer is (X1,X2,X3,X4)=(1,2,0,3)(X_1, X_2, X_3, X_4) = (1, 2, 0, 3).

Sample Input 2

3 7
.......
.......
.......

Sample Output 2

0 0 0 0 0 0 0

There may be no square that contains a box.

Sample Input 3

8 3
.#.
###
.#.
.#.
.##
..#
##.
.##

Sample Output 3

2 7 4

Sample Input 4

5 47
.#..#..#####..#...#..#####..#...#...###...#####
.#.#...#.......#.#...#......##..#..#...#..#....
.##....#####....#....#####..#.#.#..#......#####
.#.#...#........#....#......#..##..#...#..#....
.#..#..#####....#....#####..#...#...###...#####

Sample Output 4

0 5 1 2 2 0 0 5 3 3 3 3 0 0 1 1 3 1 1 0 0 5 3 3 3 3 0 0 5 1 1 1 5 0 0 3 2 2 2 2 0 0 5 3 3 3 3

update @ 2024/3/10 11:32:16