QOJ.ac

QOJ

حد الوقت: 2 s حد الذاكرة: 256 MB مجموع النقاط: 100

#22419. הפרה האבירתית

الإحصائيات

Farmer John החליף אחת מפרותיו בזו ש-Farmer Don מכנה ״The Knight״. היא קופצת כפרש בשחמט: שתי משבצות הצדה ואחת למעלה, או שתיים למטה ואחת הצדה וכו'. אינה נוחתת על סלעים או עצים, אך נעה היטב במרעה של $X$ על $Y$ משבצות ($1 \le X \le 150$; $1 \le Y \le 150$).

״The Knight״ אוהבת חציר. מפה נותנת התחלה, עצים, שיחים, סלעים ומכשולים אחרים וחבילת חציר. כמה קפיצות נדרשות? K הפרה, * מכשולים, H חציר. מפה טיפוסית:

                    11 | . . . . . . . . . .
                    10 | . . . . * . . . . . 
                     9 | . . . . . . . . . . 
                     8 | . . . * . * . . . . 
                     7 | . . . . . . . * . . 
                     6 | . . * . . * . . . H 
                     5 | * . . . . . . . . . 
                     4 | . . . * . . . * . . 
                     3 | . K . . . . . . . . 
                     2 | . . . * . . . . . * 
                     1 | . . * . . . . * . . 
                     0 ----------------------
                                           1 
                       0 1 2 3 4 5 6 7 8 9 0

המסלול A, B, C וכו' מגיע ב-5 קפיצות (ייתכנו אחרים באורך 5):

                    11 | . . . . . . . . . .
                    10 | . . . . * . . . . .
                     9 | . . . . . . . . . .
                     8 | . . . * . * . . . .
                     7 | . . . . . . . * . .
                     6 | . . * . . * . . . F<
                     5 | * . B . . . . . . .
                     4 | . . . * C . . * E .
                     3 | .>A . . . . D . . .
                     2 | . . . * . . . . . *
                     1 | . . * . . . . * . .
                     0 ----------------------
                                           1
                       0 1 2 3 4 5 6 7 8 9 0

רמז: כנראה הכי פשוט תור ראשון נכנס, ראשון יוצא, הממומש בכמה מערכים מקבילים.

קלט

  • שורה 1: שני שלמים $X$, $Y$ מופרדים ברווח.
  • שורות $2..Y+1$: שורה $Y-i+2$ מכילה $X$ תווים ללא רווחים לשורה $i$ במפה (נקראת בסדר התרשים לעיל).

פלט

  • שורה 1: שלם, מינימום קפיצות לחציר. תמיד ניתן להגיע.

דוגמאות

קלט 1

10 11
..........
....*.....
..........
...*.*....
.......*..
..*..*...H
*.........
...*...*..
.K........
...*.....*
..*....*..

פלט 1

5

מחבר הבעיה: Rob Kolstad, 2009

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.