编程介的小学生 2017-02-18 14:32 采纳率: 20.5%
浏览 727
已采纳

Die and Chessboard

Imagine you have a six-sided die standing on infinite chessboard that have that have field side length exactly equal to die edge length. You can move die onto the north, south, west or east directions by turning the die around the corresponding edge. Your goal is to find any sequence of such moves that would bring the die from initial position (includes initial orientation of the die) into it's target position that would be specified in the input data so that target digit (also specified by input data) becomes written on a die's upper side.

Initial die orientation is as follows: top side - 1, bottom side - 2, north side - 3, south side - 4, west side - 5, east side - 6. Initial die position is (0, 0). First digit in a position represents west-to-east direction (greater number - to east) and the second one - south-to-north position (greater number - to north).

This problem contains multiple test cases!

The first line of a multiple input is an integer N, then a blank line followed by N input blocks. Each input block is in the format indicated in the problem description. There is a blank line between input blocks.

The output format consists of N output blocks. There is a blank line between output blocks.

Input

The input consists of single line that contains three integers: -1000 <= X <= 1000 - desired west-to-east position of the die, -1000 <= Y <= 1000 - desired south-to-north position of the die and 1 <= M <= 6 - number that should be at top when die is finished moving.

Output

Output should contain a route that solves the problem coded as follows: S - going south, N - going north, E - going east, W - going west. As the last step of the route is executed the die should stand in a desired location with a desired digit on upper side. Route steps should be printed without any spaces between grouped in some lines so all the lines (probably excluding last one) contain exactly 80 characters (route steps).

Sample Input

1

1 1 5

Sample Output

NE

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-02-22 14:15
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 steam下载游戏占用内存
  • ¥15 树莓派5怎么用camera module 3啊
  • ¥20 java在应用程序里获取不到扬声器设备
  • ¥15 echarts动画效果的问题,请帮我添加一个动画。不要机器人回答。
  • ¥15 Attention is all you need 的代码运行
  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事:
  • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
  • ¥80 部署运行web自动化项目
  • ¥15 腾讯云如何建立同一个项目中物模型之间的联系