QOJ.ac

QOJ

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

#22349. 농장 지키기

Statistics

농장에는 언덕이 많으며 Farmer John은 소중한 젖소의 안전을 위해 경비원을 배치하려 합니다.

각 정상에 한 명씩 두려면 몇 명이 필요할까요? 지도는 $N$행 $(1 \lt N \le 700)$, $M$열 $(1 \lt M \le 700)$의 정수 행렬이며 각 원소는 고도 $H_{ij}$ $(0 \le H_{ij} \le 10,000)$입니다. 정상 수를 구해 도우세요.

정상은 같은 값의 인접한 원소 하나 이상이며, 주위에는 지도 가장자리나 더 낮은 고도의 원소만 있습니다. 서로 다른 두 원소는 $X$ 좌표 차의 절댓값이 1 이하이고 $Y$ 좌표 차의 절댓값도 1 이하이면 인접합니다.

입력

  • 줄 1: 공백으로 구분한 두 정수 $N$과 $M$입니다.
  • 줄 $2,\ldots,N+1$: 줄 $i+1$은 공백으로 구분한 $M$개 정수 $H_{ij}$로 행렬의 $i$번째 행을 나타냅니다.

출력

  • 줄 1: 정상 수인 정수입니다.

예제

입력 1

8 7
4 3 2 2 1 0 1
3 3 3 2 1 0 1
2 2 2 2 1 0 0
2 1 1 1 1 0 0
1 1 0 0 0 1 0
0 0 0 1 1 1 0
0 1 2 2 1 1 0
0 1 1 1 2 1 0

출력 1

3

참고

정상은 세 곳입니다. 왼쪽 위 높이 4인 점, 아래쪽 높이 2인 점 중 하나, 오른쪽 위 모서리 높이 1인 점 중 하나입니다.

문제 출제: Fatih Gelgi, 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.