#P9037. [PA 2021] Autostrada
[PA 2021] Autostrada
Problem Description
Agent Karol is driving his red car on a three-lane highway. In front of him there are some cars, and all of them are moving forward at a fixed speed that depends on the lane: the speed of lane is , and . Other cars never change lanes or speed, but Karol can change lanes instantly, and can also instantly change his own speed to any real value not exceeding . He cannot turn around, so his speed is within the interval .
Including Karol, every car has length . Cars may collide with each other, but Karol must not allow any two cars to collide, i.e., they must not overlap with a positive-length intersection. Formally, define a car’s position as the distance between its front bumper and the start of the highway (i.e., Karol’s initial position). For two cars in the same lane, the difference of their positions must not be less than .
Near the entrance there is a road segment of length , and Karol is currently at the start of the third lane. The highway extends infinitely, and outside the described segment there are no cars on the highway.
Compute the minimum time after which Karol can overtake all cars. In other words, compute the minimum time after which every other car can be completely behind Karol’s rear bumper.
Note: Karol may change his lane and speed at non-integer times, and car positions may also be non-integers.
Input Format
The first line contains five integers .
The next three lines contain strings of length . Line describes lane : if the -th character of is #, then there is a car at that position; if it is ., then there is no car at that position. It is guaranteed that the first characters of and are ., and the first character of is #, which represents Karol’s car. There are at least two # characters in the input.
Output Format
Output one real number: the minimum time needed for Karol to overtake all cars.
Any output with absolute or relative error within compared to the standard answer will be accepted. That is, if your answer is and the standard answer is , then your output is considered correct if .
5 60 15 10 9
.#...
..#.#
###..
0.644444444444444
6 140 120 115 110
.##...
......
#.#.#.
0.166666666666667
Hint
Constraints: for of the testdata, , .
Translated by ChatGPT 5