In order to expand its reach to the outer universe and ensure universal peace, the MIB has decided to expand its offices. Namely, it has established its office on NN most important planets in the universe, with the base station on the planet S. Each office has an intergalactic teleporter that connects it to other planet offices. But the teleporters are bound to a planet's policy, so you cannot teleport to any planet you wish. Due to intergalactic feuds, the planets are divided into KK different alliances, numbered 1 through KK. You know for each planet i, the alliance that it belongs to. In other words, you're given a sequence A1,A2...,An, which says that planet ii belongs to alliance A_{i}. Each planet ii has a policy of teleportation to the planets of other alliances: Cost to travel from one planet to another is determined by the alliance of the destination planet. More formally, the cost to reach a planet which belongs to alliance j from planet ii is represented as C_{i, j}. Intra-alliance travel is free, i.e., if A_{i} = j, then C_{i, j} = 0 For a planet ii, there are some forbidden alliances as well. For these alliances, C_{i, j} = -1, given that alliance j is forbidden to travel from planet i. As MIB is bound to follow the intergalactic rules and since they have limited funds (yes, the government is cheap everywhere), they have decided to find the most optimal way to travel to each of the planets from the base station at planet SS. With all other agents busy with their missions, you are assigned the task to find these minimum-cost paths. This is your first task in MIB, so don't let

Operations Research : Applications and Algorithms
4th Edition
ISBN:9780534380588
Author:Wayne L. Winston
Publisher:Wayne L. Winston
Chapter20: Queuing Theory
Section: Chapter Questions
Problem 17RP
icon
Related questions
Question
Answer in C++ only
In order to expand its reach to the outer universe and ensure universal peace, the MIB has decided
to expand its offices. Namely, it has established its office on NN most important planets in the
universe, with the base station on the planet S. Each office has an intergalactic teleporter that
connects it to other planet offices. But the teleporters are bound to a planet's policy, so you cannot
teleport to any planet you wish. Due to intergalactic feuds, the planets are divided into KK different
alliances, numbered 1 through KK. You know for each planet i, the alliance that it belongs to. In other
words, you're given a sequence A1,A2...,An, which says that planet ii belongs to alliance A_{i}.
Each planet ii has a policy of teleportation to the planets of other alliances:
Cost to travel from one planet to another is determined by the alliance of the destination
planet. More formally, the cost to reach a planet which belongs to alliance j from planet ii is
represented as C_{i, j}. Intra-alliance travel is free, i.e., if A_{i} = j, then C_{i, j} = 0
For a planet ii, there are some forbidden alliances as well. For these alliances, C_{i, j} = -1,
given that alliance j is forbidden to travel from planet i.
As MIB is bound to follow the intergalactic rules and since they have limited funds (yes, the
government is cheap everywhere), they have decided to find the most optimal way to travel to each
of the planets from the base station at planet SS. With all other agents busy with their missions, you
are assigned the task to find these minimum-cost paths. This is your first task in MIB, so don't let
them down!
Input
534
13122
05-1
-140
03-1
40-1
403
Output
43400
Transcribed Image Text:Answer in C++ only In order to expand its reach to the outer universe and ensure universal peace, the MIB has decided to expand its offices. Namely, it has established its office on NN most important planets in the universe, with the base station on the planet S. Each office has an intergalactic teleporter that connects it to other planet offices. But the teleporters are bound to a planet's policy, so you cannot teleport to any planet you wish. Due to intergalactic feuds, the planets are divided into KK different alliances, numbered 1 through KK. You know for each planet i, the alliance that it belongs to. In other words, you're given a sequence A1,A2...,An, which says that planet ii belongs to alliance A_{i}. Each planet ii has a policy of teleportation to the planets of other alliances: Cost to travel from one planet to another is determined by the alliance of the destination planet. More formally, the cost to reach a planet which belongs to alliance j from planet ii is represented as C_{i, j}. Intra-alliance travel is free, i.e., if A_{i} = j, then C_{i, j} = 0 For a planet ii, there are some forbidden alliances as well. For these alliances, C_{i, j} = -1, given that alliance j is forbidden to travel from planet i. As MIB is bound to follow the intergalactic rules and since they have limited funds (yes, the government is cheap everywhere), they have decided to find the most optimal way to travel to each of the planets from the base station at planet SS. With all other agents busy with their missions, you are assigned the task to find these minimum-cost paths. This is your first task in MIB, so don't let them down! Input 534 13122 05-1 -140 03-1 40-1 403 Output 43400
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Device network connection
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Operations Research : Applications and Algorithms
Operations Research : Applications and Algorithms
Computer Science
ISBN:
9780534380588
Author:
Wayne L. Winston
Publisher:
Brooks Cole