Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Every house in the colony has at most one pipe going into it and at most one pipe going out of it. Tanks and taps
Every house in the colony has at most one pipe going into it and at most one pipe going out of it. Tanks and taps are to be installed in a manner such that every house with one outgoing pipe but no incoming pipe gets a tank installed on its roof and every house with only an incoming pipe and no outgoing pipe gets a tap. Find the efficient way for the construction of the network of pipes. Input The first line contains two integer N \& P denoting the number of houses and number of pipes respectively. Next P lines contain 3 integer inputs a. b \& d, d denoting P denoting the number of houses and number of pipes respectively. Next P lines contain 3 integer inputs a, b \& d, d denoting the diameter of the pipe from the house a to house b. Output: For each test case, the output is the number of pairs of tanks and taps installed i.e N followed by N lines that contain three integers: house number of tank, house number of tap and the minimum diameter of pipe between them. 1. limport java.util.*; 2 class Testclass 3+{ static void solve(int arr[][],int n, int p ) \{ //write your code here \} public static void main(String[] args) \{ TestClass obj = new TestClass (); Scanner in = new Scanner(System.in); int n=innextInt(); int p=innextInt(); int ar[][]= new int[p][3]; for(int i=0;i
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