Answered step by step
Verified Expert Solution
Question
1 Approved Answer
You are a tour guide in a coastal city and there are N islands and ) you need to organize in the country. Each island
You are a tour guide in a coastal city and there are islands and
you need to organize in the country. Each island has a port and each port can work as layover. The
port will be in two states, loading and running. In loading state, people get on the boats. In the
running state, boats will leave the port for the next island. All the ports will switch their states from
loading to running and vice versa after every minutes. At a port, if its state is loading, you have
to wait for it to switch its state to running. At the beginning, all the ports are in running state. The
time taken to travel through any boat route is minutes. Find the lexicographically smallest path
which will take the minimum amount of time in minutes required to move from island to island
In the input, the first line contains space separated integers, and denotes the
number of islands we have, denotes the number of connections between the islands, denotes
the time required by ports to change their states and denotes that the time for traveling one island
to another. Next lines contain two spaceseparated integers each, and denoting that there is
a bidirectional road between island and island Next line contains two spaceseparated
integers, the island we start to travel and the island we want to reach at the end.
In the first line it is given that we have islands and bidirectional boat roads between
them. For this case, time required the ports to change their state is minutes and travel through
any boat route is minutes. The next lines gives the connections between the islands and the last
line gives which island is the starting point and which island is the end point for this case.
Sample Input:
In the output, the first line prints an integer denoting the number of islands you need to
go through to reach island from the island In next line, print spaceseparated integers
denoting the path which will take the minimum amount of time in minutes required by to move
from island to island In the last line, print the total time through the path from island to
island Y There can be multiple paths. Print the lexicographically smallest one and then the total
time for each path at the end.
The output for the above inputs as follows. Please check your program with this input as
well as the others that you will create. Please note that we may use other inputs when grading your
assignments.
Sample Output:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started