#abc280a. A - Pawn on a Grid

A - Pawn on a Grid

Score : 100100 points

问题描述

存在一个网格,从上到下有 HH 行,从左到右有 WW 列。每个格子上都放置了一个棋子或为空。

网格的状态由 HH 个长度为 WW 的字符串 S1,S2,,SHS_1, S_2, \ldots, S_H 表示。
如果 SiS_i 的第 jj 个字符是 #,则表示从顶部数第 ii 行、从左边数第 jj 列的格子上有一个棋子;
如果 SiS_i 的第 jj 个字符是 ., 则表示从顶部数第 ii 行、从左边数第 jj 列的格子为空。

请问网格中有多少个格子上有棋子?

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

Problem Statement

There is a grid with HH rows from top to bottom and WW columns from left to right. Each square has a piece placed on it or is empty.

The state of the grid is represented by HH strings S1,S2,,SHS_1, S_2, \ldots, S_H, each of length WW.
If the jj-th character of SiS_i is #, the square at the ii-th row from the top and jj-th column from the left has a piece on it;
if the jj-th character of SiS_i is ., the square at the ii-th row from the top and jj-th column from the left is empty.

How many squares in the grid have pieces on them?

Constraints

  • 1H,W101\leq H,W \leq 10
  • HH and WW are integers.
  • SiS_i is a string of length WW consisting of # and ..

Input

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

HH WW

S1S_1

S2S_2

\vdots

SHS_H

Output

Print the number of squares with pieces as an integer.

Sample Input 1

3 5
#....
.....
.##..

Sample Output 1

3

The following three squares have pieces on them:

  • the square at the 11-st row from the top and 11-st column from the left;
  • the square at the 33-rd row from the top and 22-nd column from the left;
  • the square at the 33-rd row from the top and 33-rd column from the left.

Thus, 33 should be printed.

Sample Input 2

1 10
..........

Sample Output 2

0

Since no square has a piece on it, 00 should be printed.

Sample Input 3

6 5
#.#.#
....#
..##.
####.
..#..
#####

Sample Output 3

16

update @ 2024/3/10 11:45:49

}