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$ 度回転させる.

Right,Left の $2$ つの操作は上下の面はそのままで水平方向に $90$ 度回転させる.(回転させる向きに要注意.)

初期配置で上の面に出ている目 $1$ を初期値とし,$1$ 回の操作が終わるたびに,上の面に出ている目の数を加算していき,指示にしたがってすべての操作を終えたときの合計値を出力するプログラムを作成しなさい.

入力ファイルの $1$ 行目には総指示回数 $n$ が書かれていて,続く $n$ 行の各行には「North,East,South,West,Right,Left」のいずれか $1$ つの指示が書かれているものとする.ただし,$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.