10248_BasicWallMaze

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

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

Pro.ID

10248

Title

Basic Wall Maze

Title链接

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

AC

0

Submit

9

Ratio

0.00%

时间&空间限制

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

    In this problem you have to solve a very simple maze consisting of:

    1. a 6 by 6 grid of unit squares

    2. 3 walls of length between 1 and 6 which are placed either horizontally or vertically to separate squares

    3. one start and one end marker

    A maze may look like this:

    You have to find a shortest path between the square with the start marker and the square with the end marker. 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.

    输入

    The input consists of several test cases. Each test case consists of five lines: The first line contains the column and row number of the square with the start marker, the second line the column and row number of the square with the end marker. The third, fourth and fifth lines specify the locations of the three walls. The location of a wall is 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 is given as the distance from the left side of the grid followed by the distance from the upper side of the grid.

    You may assume that the three walls don't intersect with each other, although they may touch at some grid corner, and that the wall endpoints are on the grid. Moreover, there will always be a valid path from the start marker to the end marker. Note that the sample input specifies the maze from the picture above.

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

    输出

    Description

    In this problem you have to solve a very simple maze consisting of:

    1. a 6 by 6 grid of unit squares

    2. 3 walls of length between 1 and 6 which are placed either horizontally or vertically to separate squares

    3. one start and one end marker

    A maze may look like this:

    You have to find a shortest path between the square with the start marker and the square with the end marker. 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.

    Input

    The input consists of several test cases. Each test case consists of five lines: The first line contains the column and row number of the square with the start marker, the second line the column and row number of the square with the end marker. The third, fourth and fifth lines specify the locations of the three walls. The location of a wall is 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 is given as the distance from the left side of the grid followed by the distance from the upper side of the grid.

    You may assume that the three walls don't intersect with each other, although they may touch at some grid corner, and that the wall endpoints are on the grid. Moreover, there will always be a valid path from the start marker to the end marker. Note that the sample input specifies the maze from the picture above.

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

    Output

    For each test case print a description of a shortest path from the start marker to the end marker. The description should specify the direction of every move ( 'N' for up, 'E' for right, 'S' for down and 'W' for left ).

    There can be more than one shortest path, in this case you can print any of them.

    Sample Input

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

    Sample Output

    NEEESWW

    Source

    样例输入

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

    样例输出

    NEEESWW

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部