[Solution] Second Flight Meta Hacker Cup Qualification Round Solution
Meta Getaways is a travel agency that deals with airports numbered , and flight paths. Flight path connects airports and in both directions, with two direct flights operating every morning (one in each direction), and another two every evening (also one in each direction). Each of these four direct flights can carry up to tourists.
The first sample case is depicted above, with morning and evening flights in red and blue.
Peak travel season is here, and will last days. For each day , determine , the maximum number of tourists who could possibly fly from airport to . Each tourist may either fly directly or take one morning and one evening flight which share an intermediate airport.
Constraints
All unordered pairs within a given test case are distinct.
The sum of across all test cases is at most .
Input Format
Input begins with a single integer , the number of test cases. For each case, there is first a line containing three space-separated integers , , and . Then, lines follow, the th of which contains three space-separated integers , , and . Then, lines follow, the th of which
👇👇👇👇👇
contains two space-separated integers and .
Output Format
For the th case, print a line containing "Case #i: " followed by space-separated integers .
Sample Explanation
In the first case:
- On day , we must send as many tourists from airport to airport . We can fly tourists direct in the morning and more at night. Only tourists can be flown from in the morning and in the evening (despite the evening flight capacity being ). Therefore, .
- On day , we can fly tourists direct in the morning and evening, then fly tourists through airports . Therefore, .
- On day , there are no direct flights. We can fly tourists through airports , and tourists through airports for a total of tourists.
In the second case:
No comments:
Post a Comment