QOJ.ac

QOJ

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

#23748. Dice

Statistics

A die is placed in the orientation shown in the figure below.

problem_23748_304c8f4f0d7bcdf755f610a4d1534eee.png

For the die used here, as shown in this figure, when $1$ is on the top face and $2$ is on the south face, $3$ is on the east face. Since the sum of opposite faces of a die is always $7$, the hidden faces are $5$ on the north side, $4$ on the west side, and $6$ on the bottom side, respectively.

Starting from this initial configuration, we move the die according to instructions. Each instruction performs one of the following $6$ operations a number of times.

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

Each of the operations North, East, South, and West rotates the die by $90$ degrees in the indicated direction.

The $2$ operations Right and Left rotate the die by $90$ degrees horizontally while keeping the top and bottom faces as they are. (Be careful of the direction of rotation.)

Taking the number $1$ appearing on the top face in the initial configuration as the initial value, each time $1$ operation finishes, add the number appearing on the top face, and write a program that outputs the total sum when all operations have been completed according to the instructions.

Line $1$ of the input file contains the total number of instructions $n$, and each of the following $n$ lines contains $1$ instruction chosen from "North, East, South, West, Right, Left". Here, $n \le 10000$.

In the output file to be uploaded, insert a newline after the output (the total value).

Examples

Input 1

5
North
North
East
South
West

Output 1

21

Input 2

8
West
North
Left
South
Right
North
Left
East

Output 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.