当前位置:网站首页>poj2935 Basic Wall Maze (2016xynu暑期集训检测 -----D题)
poj2935 Basic Wall Maze (2016xynu暑期集训检测 -----D题)
2022-08-05 10:26:00 【51CTO】
Description
In this problem you have to solve a very simple maze 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:
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
如果去掉障碍 那么就是一道dijkstra的最短路径 题
既然有了障碍 那么就处理障碍
把障碍相隔的两个点 设置为不能通过
剩下就是bfs了
边栏推荐
- How does the official account operate and maintain?Public account operation and maintenance professional team
- uniapp 连接ibeacon
- Technical dry goods | Hausdorff distance for image segmentation based on MindSpore
- Ali's new launch: Microservices Assault Manual, all operations are written out in PDF
- 语音社交软件开发——充分发挥其价值
- 教你本地编译运行一个IDEA插件,在IDEA里聊天、下棋、斗地主!
- Create a Dapp, why choose Polkadot?
- 电气工程的标准是什么
- 什么是 DevOps?看这一篇就够了!
- Our Web3 Entrepreneurship Project, Yellow
猜你喜欢
High-quality DeFi application building guide to help developers enjoy DeFi Summer
数据中台建设(十):数据安全管理
How to choose coins and determine the corresponding strategy research
Pycharm 常用外部工具
阿里顶级架构师多年总结的JVM宝典,哪里不会查哪里!
FPGA: Use of the development environment Vivado
产品太多了,如何实现一次登录多产品互通?
单片机:温度控制DS18B20
NowCoderTOP35-40 - continuous update ing
高质量 DeFi 应用构建指南,助力开发者玩转 DeFi Summer
随机推荐
Voice-based social software development - making the most of its value
Confessing in the era of digital transformation: Mai Cong Software allows enterprises to use data in the easiest way
MySQL data view
数据中台建设(十):数据安全管理
第八章:activiti多用户任务分配
SQL Outer Join Intersection, Union, Difference Query
Microcontroller: temperature control DS18B20
第四章:activiti RuntimeService设置获和取流程变量,及与taskService的区别,开始和完成任务时设置流程变量[通俗易懂]
MySQL事务
First Decentralized Heist?Loss of nearly 200 million US dollars: analysis of the attack on the cross-chain bridge Nomad
第四章:redis 数组结构的set和一些通用命令「建议收藏」
数分面试(一)----与业务相关
The difference between find, matches, lookingAt matching strings in matcher
第三章 : redis数据结构种类
Wei Dongshan Digital Photo Frame Project Learning (6) Transplantation of tslib
Login function and logout function (St. Regis Takeaway)
力扣(LeetCode)216. 组合总和 III(2022.08.04)
入门 Polkadot 平行链开发,看这一篇就够了
MySQL之数据视图
The query that the user's test score is greater than the average score of a single subject