编程介的小学生 2016-12-26 15:10 采纳率: 20.5%
浏览 845
已采纳

Construct the Wall Maze

Description

In this problem you have to construct a maze using a maze construction kit consisting of:

a 6 by 6 grid of unit squares
3 walls of length between 1 and 6 which are placed either horizontally or vertically to separate squares
one start and one end marker
A maze may look like this:

When a maze is finished, a shortest path between the square with the start marker and the square with the end marker is determined. Only moves between adjacent grid squares are allowed; adjacent means that the grid squares share an edge and are not separated by a wall. It is not allowed to leave the grid.

Your task is: given a shortest path of some maze, construct this maze. Obviously, the maze you construct should be valid, i.e., all 3 walls should be used, they should not intersect with each other (although they may touch at some grid corner), and the walls should not stick out of the grid. Moreover, the given path should be valid for this maze, i.e., it should lead from the square with the start marker to the square with the end marker without crossing any wall or going outside of the grid, and there shouldn’t exist any shorter valid path.

Input

The input consists of several test cases. Every test case starts with a line containing three positive integers, the length of the three walls of the maze construction kit. The next line consists of 1 to 25 characters from the set {‘N’, ‘E’, ‘S’, ‘W’} and describes a shortest path from the start to the end marker in the maze to be constructed. Each character specifies the direction of the next move (see picture). You may assume that each test case has at least one solution.

The last test case is followed by a line containing three zeros.

Output

For each test case produce five lines of output: First the column and row number of the square containing the start marker, then the column and row number of the square containing the end marker, then the location of the three walls (in the same order as the given lengths in the input). The location of a wall should be specified by either the position of its left end point followed by the position of its right end point (in case of a horizontal wall) or the position of its upper end point followed by the position of its lower end point (in case of a vertical wall). The position of a wall end point should be given as the distance from the left side of the grid followed by the distance from the upper side of the grid.

There can be several valid solutions for a given test case (for example the test case in the sample input). Your program may print any of those solutions. Note that the sample output specifies the maze from the picture above.

Sample Input

1 1 2
NEEESWW
0 0 0
Sample Output

1 6
2 6
0 0 1 0
1 5 1 6
1 5 3 5

  • 写回答

1条回答 默认 最新

  • threenewbee 2016-12-26 16:17
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求chat4.0解答一道线性规划题,用lingo编程运行,第一问要求写出数学模型和lingo语言编程模型,第二问第三问解答就行,我的ddl要到了谁来求了
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果