Company: Tower research_5sep
Difficulty: medium
Compatible Warehouses Problem Description There is a network of warehouses represented as an undirected weighted rooted tree with warehouse_nodes nodes, rooted at warehouse 1. There are warehouse_nodes - 1 roads connecting them, with warehouse_weight[i] denoting the distance of the i th road. Each warehouse has a value assigned to it in the array val . A pair of warehouses (u, v) is compatible if: u is an ancestor of v in the tree network distance(u, v) <= val[v] , where distance(u, v) is the sum of road distances in the simple path connecting u and v Your task is to find the number of compatible pairs of warehouses in a network. Function Description Complete the function countCompatiblePairs in the editor with the following parameters: int warehouse_nodes : the number of warehouses in the tree network vector<int> warehouse_from : warehouse_from[i] element is one endpoint of the i th road vector<int> warehouse_to : warehouse_to[i] element is the other endpoint of the i t