#P3096. [USACO13DEC] Vacation Planning G
[USACO13DEC] Vacation Planning G
Description
Air Bovinia operates flights connecting the farms that the cows live on (). As with any airline, of these farms have been designated as hubs (, ).
Currently, Air Bovinia offers one-way flights (), where flight travels from farm to farm and costs dollars (). As with any other sensible airline, for each of these flights, at least one of and is a hub. There is at most one direct flight between two farms in any given direction, and no flight starts and ends at the same farm.
Bessie is in charge of running the ticketing services for Air Bovinia. Unfortunately, while she was away chewing on delicious hay for a few hours, one-way travel requests for the cows' holiday vacations were received (), where the th request is from farm to farm .
As Bessie is overwhelmed with the task of processing these tickets, please help her compute whether each ticket request can be fulfilled, and its minimum cost if it can be done.
To reduce the output size, you should only output the total number of ticket requests that are possible, and the minimum total cost for them. Note that this number might not fit into a -bit integer.
In other words, given a directed graph with nodes and edges, for each query find the shortest path whose route must pass through at least one node with an index in .
Input Format
- Line : The integers , , , and .
- Lines : Line contains , , and . (, .)
- Lines : Each of these lines contains the ID of a single hub (in the range ).
- Lines : Two numbers per line, indicating a request for a ticket from farm to . (, .)
Output Format
- Line : The number of ticket requests that can be fulfilled.
- Line : The minimum total cost of fulfilling the possible ticket requests.
3 3 1 2
1 2 10
2 3 10
2 1 5
2
1 3
3 1
1
20
Hint
For the first flight, the only feasible route is , costing . There are no flights leaving farm , so the poor cows are stranded there.
Translated by ChatGPT 5
京公网安备 11011102002149号