QOJ.ac

QOJ

Limite de temps : 7 s Limite de mémoire : 512 MB Points totaux : 10

#2126. Highway [B]

Statistiques

Agent Karol is in his red car, driving on a three-lane highway. In front of him are other cars, each moving forward at a constant speed depending on the lane: $v_i$ on the $i$-th lane ($v_1 > v_2 > v_3$). None of them change their speed or lane. Karol, however, can instantly change his lane to an adjacent one. He can also instantly change his speed to any real number not exceeding $v_0$ ($v_0 > v_1$). He cannot reverse, so he always drives forward at a speed in the range $[0, v_0]$.

Each car, including Karol's, has a length of 1. Cars may touch, but Karol cannot cause a collision, which is defined as having a positive intersection area. Formally, let us define the position of a car as the distance between the front of the car and the start of the highway (the place where the front of Karol's car was initially located). The positions of two cars in the same lane cannot differ by less than 1. Remember that the speeds of the other cars are constant.

The input describes a segment of the highway of length $L$, and Karol is currently at the beginning of the third lane. The highway extends infinitely and is empty beyond the described segment.

Calculate how quickly Karol can overtake all other cars. In other words, determine the minimum time after which all other cars are completely behind the rear of Karol's car—their positions must be at least 1 less than the position of Karol's car.

Input

The first line of input contains five integers $L, v_0, v_1, v_2, v_3$ ($2 \le L \le 200\,000$; $1 \le v_3 < v_2 < v_1 < v_0 \le 140$).

The $i$-th of the next three lines contains a word $s_i$ of length $L$, describing the $i$-th lane of the highway. The $j$-th character of the word $s_i$ is '#' if there is a car at this position, and '.' otherwise.

The first character of words $s_1$ and $s_2$ is '.', and the first character of $s_3$ is '#', representing Agent Karol's car. There are at least two '#' characters in the input in total.

The input format implies that the initial positions of all cars are integers. However, Karol can change his lane and speed at non-integer moments, and thus the positions of the cars may be non-integers.

Output

The output should contain a single real number – the minimum possible time after which Agent Karol overtakes all cars on the highway. A relative or absolute error of $10^{-9}$ is acceptable.

Formally: if the exact result is $p$, your answer $x$ will be accepted if $|p - x| \le \max(1, p) \cdot 10^{-9}$.

Examples

Input 1

5 60 15 10 9
.#...
..#.#
###..

Output 1

0.644444444444444

Note

Karol's car is, of course, red.

Agent Karol instantly changes lanes from the third to the second, and immediately from the second to the first.

He drives in the first lane just behind the car with speed $v_1 = 15$, until he overtakes the first of the two cars in the second lane.

He changes lanes from the first to the second, and immediately from the second to the third.

He drives at his maximum speed $v_0 = 60$ until he overtakes all cars.

Figure 1. Initial state of the highway at T=0 for Example 1.

Input 2

6 140 120 115 110
.##...
......
#.#.#.

Output 2

0.166666666666667

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
EditorialOpen Official EditorialQingyu- Download

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.