Computer Science Question   The first line consist a number X i.e., the number of test cases. The first line consists three space-separated integers N, Q1, and Q1. Then Q1 lines follow, each containing a description of a road proposed0. Each of these lines contains three space-separated integers p, q, and r, where p and q denote the end points of the road and r denotes the associated cost. Then Q1 lines follow, each containing a description of a road proposed by Brian's company in the same format. Output a single line for each test case. If it is impossible to choose a subset of the roads in such a way that for each pair of cities, there is exactly one path of roads connecting them, output a single line containing "No way" for that test case. Otherwise, output a single line containing two space-separated integers: the maximum profit Brian can gain and the minimum total cost of the chosen roads that yields the maximum profit. Input: 1 3 1 1 0 1 1 0 1 3 Output: No way

Operations Research : Applications and Algorithms
4th Edition
ISBN:9780534380588
Author:Wayne L. Winston
Publisher:Wayne L. Winston
Chapter17: Markov Chains
Section: Chapter Questions
Problem 3RP
icon
Related questions
Question

Computer Science Question

 

The first line consist a number X i.e., the number of test cases. The first line consists three space-separated integers N, Q1, and Q1. Then Q1 lines follow, each containing a description of a road proposed0. Each of these lines contains three space-separated integers p, q, and r, where p and q denote the end points of the road and r denotes the associated cost. Then Q1 lines follow, each containing a description of a road proposed by Brian's company in the same format.
Output a single line for each test case. If it is impossible to choose a subset of the roads in such a way that for each pair of cities, there is exactly one path of roads connecting them, output a single line containing "No way" for that test case. Otherwise, output a single line containing two space-separated integers: the maximum profit Brian can gain and the minimum total cost of the chosen roads that yields the maximum profit.
Input:
1
3 1 1
0 1 1
0 1 3
Output:
No way

Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Probability Problems
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