Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

5-3 The Labyrinth of Romeo and Juliet Problem Description: The Labyrinth of Romeo and Juliet. Romeo and Juliet are in an mn maze, as shown.

image text in transcribed

5-3 The Labyrinth of Romeo and Juliet Problem Description: The Labyrinth of Romeo and Juliet. Romeo and Juliet are in an mn maze, as shown. Each square represents a room in the maze. Some of these mn rooms are closed and no one is allowed to enter. You can enter an unclosed room in 8 directions from anywhere in the maze. Romeo is in the ( p,q) square of the maze, and he has to find a way to the (r,s) square where Juliet is. Before reaching Juliet, he must walk through all the unsealed rooms once, and minimize the number of turns to Juliet. Each change of heading counts as a turn. Please design an algorithm to help Romeo find such a path: For a given Romeo and Juliet maze, program to calculate all the least-turn paths for Romeo to Juliet. data input: The first line has 3 positive integers n,m,k, which represent the number of rows, columns and closed rooms of the maze, respectively. In the next k lines, each line contains 2 positive integers, indicating the row number and column number of the closed room. The last 2 lines also contain 2 positive integers, which represent the square (p,q) where Romeo is located and the square (r,s) where Juliet is located. Result output: Take the calculated minimum number of turns from Romeo to Juliet and how many different minimum turn roads are output. The first line of the file is the minimum number of turns. Line 2 of the file is the number of different minimum turns. The next n lines each have m numbers, which represent a minimum turning road of the maze. A[i][j]=k means that the k-th step reaches square (i.j); A[i][j]=1 means that square (i,j) is closed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Explain in detail how the Mughal Empire was established in India

Answered: 1 week ago

Question

Problem: Evaluate the integral: I - -[ze dx

Answered: 1 week ago

Question

Problem: Evaluate the integral: I = 1- 1 dx 9

Answered: 1 week ago

Question

2. List the advantages of listening well

Answered: 1 week ago