当前位置:网站首页>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了
边栏推荐
- Microcontroller: temperature control DS18B20
- 深入理解 Istio 流量管理的超时时间设置
- In-depth understanding of timeout settings for Istio traffic management
- SMB + SMB2: Accessing shares return an error after prolonged idle period
- Still looking for a network backup resources?Hurry up to collect the following network backup resource search artifact it is worth collecting!
- [Translation] Chaos Net + SkyWalking: Better observability for chaos engineering
- Login function and logout function (St. Regis Takeaway)
- 第四章:activiti流程中,变量的传递和获取流程变量 ,设置和获取多个流程变量,设置和获取局部流程变量「建议收藏」
- Is digital transformation a business buy-in?
- Chapter 4: activiti RuntimeService settings get and get process variables, and the difference from taskService, set process variables when starting and completing tasks [easy to understand]
猜你喜欢
Create a Dapp, why choose Polkadot?
Introduction to SD NAND Flash!
E-sports, convenience, efficiency, security, key words for OriginOS functions
百年北欧奢华家电品牌ASKO智能三温区酒柜臻献七夕,共品珍馐爱意
three objects are arranged in a spherical shape around the circumference
单片机:温度控制DS18B20
High-quality DeFi application building guide to help developers enjoy DeFi Summer
高质量 DeFi 应用构建指南,助力开发者玩转 DeFi Summer
Huawei's lightweight neural network architecture GhostNet has been upgraded again, and G-GhostNet (IJCV22) has shown its talents on the GPU
PCB layout must know: teach you to correctly lay out the circuit board of the op amp
随机推荐
FPGA:基础入门LED灯闪烁
FPGA: Use of the development environment Vivado
单片机:温度控制DS18B20
The difference between find, matches, lookingAt matching strings in matcher
上位机开发C#语言:模拟STC串口助手接收单片机发送数据
[强网杯2022]WP-UM
What are the standards for electrical engineering
第九章:activit内置用户组设计与组任务分配和IdentityService接口的使用
js劫持数组push方法
Still looking for a network backup resources?Hurry up to collect the following network backup resource search artifact it is worth collecting!
Microcontroller: temperature control DS18B20
Technical dry goods | Hausdorff distance for image segmentation based on MindSpore
第八章:activiti多用户任务分配
STM32+ULN2003 drives 28BYJ4 stepper motor (forward and reverse according to the number of turns)
The fuse: OAuth 2.0 four authorized login methods must read
LeetCode 216. Combined Sum III (2022.08.04)
FPGA:基础入门按键控制LED灯
NowCoderTOP35-40 - continuous update ing
皕杰报表的下拉框联动
hcip BGP enhancement experiment