Farmer John accidentally ordered two GPS units for his new car. Both use the same map, but each assigns its own travel time to every road.
The map has N intersections (2≤N≤10000) and M one-way roads (1≤M≤50000). Road i runs from Ai to Bi. Multiple roads may connect the same pair of intersections, and a two-way road appears as two opposite one-way roads. FJ's house is at intersection 1 and his farm at intersection N. The farm is reachable from the house.
Road i takes Pi time according to the first GPS and Qi time according to the second (each is an integer in 1…100000).
When FJ travels from his house to the farm, a GPS complains whenever he uses a road that it does not consider part of any shortest route from the current intersection to the farm. If both GPS units complain on the same road, that adds 2 to the total.
Find the minimum total number of complaints over all routes from 1 to N.
The minimum total number of complaints.
Precompute shortest distances to the farm for each GPS, then mark roads that are not on any shortest-path edge as complaints.