Sister Cities
Time limit2sMemory limit512 MB
For each city pair, find the smallest fuel capacity that lets two cars drive to each other's city on a connected road graph without ever meeting.
- Level
Hard8 of 10
- Topics
- Graph, Minimum spanning tree, Union-find
- Solved
- No attempts yet
Problem
Indonesia has cities numbered from 0 to , and two-way roads numbered from 0 to . Each road connects two different cities. Road connects city and city , and a car needs units of gasoline to travel along it. Every pair of cities is connected by a series of roads.
For the next days, one pair of cities will try to become sister cities each day. On day , city tries to become a sister city of city . To do this, city sends a delegation by car to city , and city sends a delegation by car to city .
To prevent congestion, two cars must never meet. Specifically, two cars must never be in the same city at the same time. Also, two cars must not travel the same road in opposite directions at the same time. In addition, a car that enters a road must drive to the other end and reach the destination. In other words, a car cannot turn around in the middle of a road. However, a car may visit the same city or the same road more than once. A car may also wait in any city at any time.
A large fuel tank makes a car expensive, so the two cities want routes that minimize the maximum fuel tank capacity of the two cars. Every city has a gas station with unlimited gasoline. Therefore, the fuel tank capacity a car needs is the largest amount of gasoline required on any road the car uses.
Constraints
- .
- .
- .
- At most one road connects any two cities.
- Any two cities can reach each other by one or more roads.
- .
- .
- .