QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#22328. 최고의 풀

Statistics

Bessie는 부드러운 봄풀을 먹을 하루를 계획하며 Farmer John이 정성껏 $R$행($(1 \le R \le 100)$), $C$열($(1 \le C \le 100)$)로 나눈 목초지를 봅니다. 풀 덩어리 수를 세려 합니다.

각 덩어리는 # 하나 또는 대각선이 아닌 변으로 이웃한 # 둘입니다. 지도가 주어지면 덩어리 수를 알려 주세요.

예를 들어 다음 지도는 $R$이 $5$, $C$가 $6$입니다.

.#....
..#...
..#..#
...##.
.#....

총 $5$덩어리: $1$행 하나, $2$열에서 $2$·$3$행에 걸친 하나, $3$행의 독립된 하나, $4$행에서 $4$·$5$열에 걸친 하나, $5$행 하나입니다.

입력

  • $1$번 줄: 공백으로 구분된 정수 $R$와 $C$.

  • $2,\ldots,R+1$번 줄: $i+1$번 줄은 $C$개 문자로 $i$행을 설명하며 각각 # 또는 .입니다.

출력

  • $1$번 줄: Bessie가 먹을 수 있는 풀 덩어리 수인 정수 하나.

예제

입력 1

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

출력 1

5

문제 출제자: Rob Kolstad, 2008

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.