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.