QOJ.ac

QOJ

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

#23748. קובייה

Statistics

קובייה מונחת בכיוון המתואר באיור שלהלן.

problem_23748_304c8f4f0d7bcdf755f610a4d1534eee.png

עבור הקובייה המשמשת כאן, כפי שמוצג באיור זה, כאשר בצד העליון נמצא $1$ ובצד הדרומי נמצא $2$, אזי בצד המזרחי נמצא $3$. מאחר שסכום הפאות הנגדיות בקובייה הוא תמיד $7$, הפאות הנסתרות הן $5$ בצד הצפוני, $4$ בצד המערבי ו-$6$ בצד התחתון, בהתאמה.

ממצב התחלתי זה מזיזים את הקובייה בהתאם להוראות. ההוראות מורכבות מביצוע מספר פעמים של $6$ הפעולות הבאות.

problem_23748_72d8c824c4b7e7b2153bcc762586c844.png problem_23748_351ae00444f5f85272c6e0b480784775.png problem_23748_c14159840b38cefaa3541522e15482ec.png problem_23748_348dec7a597c22f23bab6e9c675aeeca.png
problem_23748_593a588389d24d87834e078753aa4bfd.png problem_23748_d77964fb3dfcacbf2a397262f4d096a7.png

כל אחת מהפעולות North, East, South ו-West מסובבת את הקובייה ב-$90$ מעלות לכיוון המצוין.

שתי ($2$) הפעולות Right ו-Left משאירות את הפאה העליונה והפאה התחתונה במקומן ומסובבות את הקובייה ב-$90$ מעלות בכיוון האופקי. (שימו לב היטב לכיוון הסיבוב.)

הגדירו את המספר $1$ המופיע על הפאה העליונה במצב ההתחלתי כערך ההתחלתי, ובכל פעם שמסתיימת פעולה $1$ הוסיפו את המספר המופיע על הפאה העליונה; כתבו תוכנית המדפיסה את הסכום הכולל לאחר סיום כל הפעולות לפי ההוראות.

בשורה $1$ של קובץ הקלט כתוב המספר הכולל של ההוראות $n$, ובכל אחת מ-$n$ השורות הבאות כתובה הוראה $1$ מתוך "North, East, South, West, Right, Left". נתון כי $n \le 10000$.

בקובץ הפלט המועלה, יש להוסיף ירידת שורה לאחר הפלט (הסכום הכולל).

דוגמאות

קלט 1

5
North
North
East
South
West

פלט 1

21

קלט 2

8
West
North
Left
South
Right
North
Left
East

פלט 2

34

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.