Under construction

Still being built. Things may change

Dig or Climb

Time limit8sMemory limit512 MB

Summary
Given a polyline terrain cross-section, find the shortest travel time from the first point to the last, walking along the surface or tunneling horizontally between two same-height points whose interior stays below the terrain.
Level

Hard8 of 10

Topics
Graph, Shortest path, Geometry, Implementation
Solved
No attempts yet

Problem

Benjamin Forest VIII is the king of a country. His close friend Nod lives in a village far from the castle. Nod falls seriously ill and his life is in danger, so the king orders his subordinate Red to deliver good medicine as fast as possible. There is no road from the castle to the village, so Red has to climb over mountains and cross canyons to reach it.

Red travels along the shortest path on the map, the straight line between the castle and the village. The cross section of the terrain along that line is a polyline through the nn points (x1,y1),…,(xn,yn)(x_1, y_1), \dots, (x_n, y_n).

An example route from the castle to the village

Figure 1. An example route from the castle to the village

xix_i is the horizontal distance from the castle to point ii, and yiy_i is the height of point ii. The castle is at (x1,y1)(x_1, y_1) and the village is at (xn,yn)(x_n, y_n).

Red walks on the surface at speed vwv_w. He also has a skill that cuts a horizontal tunnel through a mountain, and he moves inside a mountain at speed vcv_c.

Red has two ways to move. The first is walking along the polyline, either to the left or to the right. That takes the length of the walked part of the polyline divided by vwv_w. The second is digging through a mountain. If two points (a,y)(a, y) and (b,y)(b, y) on the polyline have the same height, a<ba < b, and the terrain height is greater than yy at every xx with a<x<ba < x < b, then Red can move between the two points along the horizontal line. That takes (b−a)/vc(b - a) / v_c. If the terrain height is at most yy anywhere strictly between the two points, that stretch is not inside a mountain and cannot be dug.

Write a program that computes the minimum time to reach the village.

Input

The input is a sequence of datasets. Each dataset has the following format.

n
vw vc
x1 y1
...
xn yn

The first line holds the number of points nn. The second line holds the walking speed vwv_w and the digging speed vcv_c. Each of the next nn lines holds the coordinates xix_i and yiy_i of one point.

2≤n≤10002 \le n \le 1000, 1≤vw,vc≤101 \le v_w, v_c \le 10, −10000≤xi,yi≤10000-10000 \le x_i, y_i \le 10000, and xi<xjx_i < x_j whenever i<ji < j. Every value in the input is an integer.

The input ends with a line that holds 00 in place of nn. That line is not a dataset and must not be processed.

Output

For each dataset, print the minimum time to reach the village on its own line. Round the value to six digits after the decimal point and print all six digits. Print no other character and no extra space.

Examples3

  1. Example 1

    Input
    3
    2 1
    0 0
    50 50
    100 0
    3
    1 1
    0 0
    50 50
    100 0
    3
    1 2
    0 0
    50 50
    100 0
    3
    2 1
    0 0
    100 100
    150 50
    6
    1 2
    0 0
    50 50
    100 0
    150 0
    200 50
    250 0
    0
    
    Expected output
    70.710678
    100.000000
    50.000000
    106.066017
    150.000000
    
  2. Example 2

    Input
    2
    1 1
    0 0
    10 0
    2
    3 2
    -5 -5
    5 5
    0
    
    Expected output
    10.000000
    4.714045
    
  3. Example 3

    Input
    8
    1 5
    0 10
    20 60
    40 10
    70 10
    90 60
    110 10
    130 70
    160 10
    0
    
    Expected output
    56.000000