B - Building Heights Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 233 点

問題文

高橋君は市内のビル群を真横から見た図を持っています。図は縦 H 行、横 W 列のマス目で、 H 個の文字列 S_1, S_2, \ldots, S_H で表されます。 S_i の j 文字目は上から i 行目、左から j 列目のマスの様子で、 # はビルの一部を、 . は空を表します。

左から j 列目には j 番目のビルが建っており、その高さは j 列目に含まれる # の個数です。

W 棟のビルの高さを、左から順に出力してください。

制約

  • 1 \leq H \leq 10
  • 1 \leq W \leq 10
  • S_i は # と . のみからなる長さ W の文字列

入力

入力は以下の形式で標準入力から与えられる。

H W
S_1
S_2
\vdots
S_H
  • 1 行目には、図の行数 H と列数 W がスペース区切りで与えられる。
  • 2 行目から H 行にわたり、 1 + i 行目には上から i 行目の様子を表す文字列 S_i が与えられる。

出力

W 棟のビルの高さを、左から順にスペース区切りで 1 行に出力せよ。


入力例 1

3 3
#.#
...
#.#

出力例 1

2 0 2

入力例 2

1 1
#

出力例 2

1

入力例 3

2 2
##
##

出力例 3

2 2

入力例 4

2 2
#.
.#

出力例 4

1 1

入力例 5

3 3
#.#
.#.
#.#

出力例 5

2 1 2

Score : 233 pts

Problem Statement

Takahashi has a side-view picture of buildings in the city. The picture is a grid of H rows and W columns, represented by H strings S_1, S_2, \ldots, S_H. The j-th character of S_i describes the cell in the i-th row from the top and the j-th column from the left: # means part of a building and . means sky.

In the j-th column from the left stands the j-th building, whose height is the number of # contained in the j-th column.

Print the heights of the W buildings, from left to right.

Constraints

  • 1 \leq H \leq 10
  • 1 \leq W \leq 10
  • S_i is a string of length W consisting only of # and .

Input

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

H W
S_1
S_2
\vdots
S_H
  • The first line contains the number of rows H and the number of columns W of the picture, separated by a space.
  • For each of the next H lines, the (1 + i)-th line contains the string S_i describing the i-th row from the top.

Output

Print the heights of the W buildings from left to right, separated by spaces, on a single line.


Sample Input 1

3 3
#.#
...
#.#

Sample Output 1

2 0 2

Sample Input 2

1 1
#

Sample Output 2

1

Sample Input 3

2 2
##
##

Sample Output 3

2 2

Sample Input 4

2 2
#.
.#

Sample Output 4

1 1

Sample Input 5

3 3
#.#
.#.
#.#

Sample Output 5

2 1 2