22218_RollOverandDie

2022-5-16 18:21| 发布者: Hocassian| 查看: 20| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-5-89506208448300-Problem List-采集的数据-后羿采集器.html

Pro.ID

22218

Title

Roll Over and Die

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=22218

AC

4

Submit

17

Ratio

23.53%

时间&空间限制

  • Time Limit: 1000/500 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    A standard die is a cube on which the numbers 1, 2, 3, 4, 5, 6 appear, one per side, and the sum of numbers on opposite sides is always 7. Initially, a single die is placed on a level table in the initial position — the number 1 facing up, 2 facing north, and 3 facing west. In this problem, a roll of a die is not so much a violently tumbling throw as it is a sequence of careful topples, in each of which the die is simply tipped over onto one of the sides previously facing north, east, south or west. Write a program that can input a roll of a die and determine which number is facing up when the roll ends.

    输入

    Each line of the input represents a roll of a die starting from the initial position. Each line contains a string of zero or more characters from the alphabet {N, E, S, W}, respectively representing a successive topple to the north, east, south or west.

    输出

    Description

    A standard die is a cube on which the numbers 1, 2, 3, 4, 5, 6 appear, one per side, and the sum of numbers on opposite sides is always 7. Initially, a single die is placed on a level table in the initial position — the number 1 facing up, 2 facing north, and 3 facing west. In this problem, a roll of a die is not so much a violently tumbling throw as it is a sequence of careful topples, in each of which the die is simply tipped over onto one of the sides previously facing north, east, south or west. Write a program that can input a roll of a die and determine which number is facing up when the roll ends.

    Input

    Each line of the input represents a roll of a die starting from the initial position. Each line contains a string of zero or more characters from the alphabet {N, E, S, W}, respectively representing a successive topple to the north, east, south or west.

    Output

    For each line of input, output the number on the die that is facing up after the given roll of the die, starting from the initial position.

    Sample Input

    NNNNN
    ESSWNN
    SSSENNNW
    SENWENSWNNEWSWS

    Sample Output

    5
    6
    5
    2

    样例输入

    NNNNN
    ESSWNN
    SSSENNNW
    SENWENSWNNEWSWS

    样例输出

    5
    6
    5
    2

    提示

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部