At Uber, drivers must complete pickups and drop-offs in a specific order.
The city is modeled as an undirected weighted graph:
Nodes represent intersections.
Edges represent roads with travel time weights.
The driver:
Starts at node 1
Must visit node x
Then visit node y
Finally reach node r_nodes
Nodes may be revisited if necessary.
Task
Compute the minimum total travel time for: 1 → x → y → r_nodes
Function Signature int minTotalTime( int r_nodes, vector<int> r_from, vector<int> r_to, vector<int> r_weight, int x, int y );
Example
r_nodes = 5 r_from = [1, 2, 3, 4, 5, 1, 3] r_to = [2, 3, 4, 5, 1, 5] r_weight = [9, 11, 6, 1, 4, 10] x = 2 y = 4
Possible routes:
Graph is undirected
1 ≤ r_nodes ≤ 10^5
1 ≤ r_weight[i] ≤ 10^9