Smart City Traffic Toll System

Company: Juspay_3july

Difficulty: medium

Problem Statement

Smart City Traffic Toll System Description A smart city has an infinite number of traffic control hubs, numbered with the positive integers 1, 2, 3, ... . The hubs are joined by smart roads: there is a direct, bidirectional road between hub i and hub 2 * i ; there is a direct, bidirectional road between hub i and hub 2 * i + 1 . Because of this layout, between any two hubs there is exactly one shortest route, and every commuter always uses it. Initially every road is toll-free. To manage congestion, the traffic authority processes a list of q events, in the order given. Each event is described by four integers type , x , y , t . Toll fee update - 1 x y t : every road lying on the shortest route between hub x and hub y has its toll increased by t units. Tolls accumulate: a road that has been named by several updates carries the sum of all the amounts added to it. Travel cost calculation - 2 x y 0 : a commuter drives from hub x to hub y along the shortest route. The cost of that trip is