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.