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$ מתארת את שורת המטריצה $i$ באמצעות $M$ שלמים $H_{ij}$ מופרדים ברווחים.

פלט

  • שורה 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.