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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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!
03-1
40-1
403
Input
534
13122
05-1
-140
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! 03-1 40-1 403 Input 534 13122 05-1 -140 Output 43400
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Algebraic Expressions
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education