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: عددان صحيحان مفصولان بمسافة، $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.