QOJ.ac

QOJ

시간 제한: 2 s 메모리 제한: 256 MB 총점: 100

#20943. תור בעלי החיים

통계

בכל יום Farmer John חולב שמונה פרות: Bessie, Buttercup, Belinda, Beatrice, Bella, Blue, Betsy, Sue.

הן בררניות ודורשות $N$ אילוצים ($1 \leq N \leq 7$) על הסדר. כל אילוץ אומר ״יש לחלוב את $X$ ליד $Y$״, כלומר $X$ מיד לפני או אחרי $Y$.

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

קלט

השורה הראשונה מכילה $N$. הבאות $N$ מכילות משפט X must be milked beside Y, כאשר $X$, $Y$ שמות מתוך השמונה לעיל.

פלט

הדפיסו סדר תקף ב-8 שורות, פרה בכל שורה. אם כמה מתאימים, בחרו הראשון אלפביתית.

דוגמאות

קלט 1

3
Buttercup must be milked beside Bella
Blue must be milked beside Bella
Sue must be milked beside Beatrice

פלט 1

Beatrice
Sue
Belinda
Bessie
Betsy
Blue
Bella
Buttercup

קרדיט לבעיה: Brian Dean

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.