CSES - Counting Rooms

Xem dạng PDF

Gửi bài giải

Điểm: 1,00 (OI)
Giới hạn thời gian: 1.0s
Giới hạn bộ nhớ: 512M
Input: stdin
Output: stdout

Nguồn bài:
https://cses.fi/problemset/task/1192
Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch

You are given a map of a building, and your task is to count the number of its rooms. The size of the map is ~n \times m~ squares, and each square is either floor or wall. You can walk left, right, up, and down through the floor squares.

Input

  • The first input line has two integers ~n~ and ~m~: the height and width of the map.

Then there are ~n~ lines of ~m~ characters describing the map. Each character is either . (floor) or # (wall).

Output

  • Print one integer: the number of rooms.

Constraints

  • ~1 \le n,m \le 1000~

Example Input

5 8
########
#..#...#
####.#.#
#..#...#
########

Example Output

3

Bình luận

Hãy đọc nội quy trước khi bình luận.


Không có bình luận tại thời điểm này.