Company: juspay_15oct
Difficulty: medium
Water Pipeline Cost Management Problem Description Background: A water supply company has constructed a network of pipelines to distribute water from a central reservoir to all connected towns. The network is organized in a balanced tree structure, with the reservoir as the root. Each pipeline has a maintenance cost based on its length and condition. Objective: You need to manage this pipeline network by calculating the water transport cost between towns and updating pipeline maintenance costs as needed. Functionality Requirements: 1. Transport Cost Query: Calculate the total maintenance cost for transporting water between any two towns. 2. Cost Update Query: Adjust the maintenance cost for any specific pipeline between towns. Input Format: Network Configuration: The input contains 3 integers, N (the number of towns), R (the root town representing the reservoir), and M (where M = N-1). The next N-1 lines each contain three integers I, J, K, where I and J are two connected towns and K i