INGRED - Ingredients
You are given n cities with m bi-directional roads connecting them and the length of each road. There are two friends living in different cities who wish to collect some ingredients available at different stores to make cake. There are s such stores. They need not come back home after purchasing the ingredients. Petrol is expensive and they would hence like to travel minimum total distance (sum of distance distance traveled by both kids). Help them find out what this distance is.
(m lines of the form ai bi ci)
Here n is number of cities, m is number of roads, ai and bi are the cities(0 indexed) the roads connect and ci is the length of this road
s where s is the number of stores
(1 line containing s space separated integers indicating the city number in which the stores are located.)
(two space separated integers indicating the cities in which the two kids live)
Single integer x where x is the minimum distance that the duo will travel that is minimum sum of distance travelled by first kid and second kid.
2 ≤ n ≤ 100
1 ≤ m ≤ (n*(n-1))/2
0 ≤ a,b < n
0 ≤c≤ 1000
1 ≤ s ≤ 8
5 6 0 1 5 1 4 1 0 4 10 0 2 2 1 2 3 2 3 4 2 2 4 0 1
Problem Setter: Vidit Gupta
Is the graph is connected . IF both boys can't go to a store than what will be the answer?Last edit: 2018-06-03 02:32:19
all of the s stores must be visited or not?
Should be clear that each boy has to buy exactly s items; or both of them will buy s items?Last edit: 2016-08-27 06:41:09
lesson learnt..sort the array before using next_permutation.
Really Awesome Problem.
Awesome problem. Enjoyed solving it :)
-edit-Last edit: 2015-07-31 18:19:41
Increase the font size please
--Last edit: 2014-02-03 13:24:24