<|instruction|>
Solve the below problem. The solution should start with an abridged problem statement. Then key observations. Then full solution based on the observations. Then C++ and Python implementations with comments.

445. Dig or Climb
Time limit per test: 0.25 second(s)
Memory limit: 262144 kilobytes
input: standard
output: standard

Benjamin Forest VIII is a king of a country. One of his best friends Nod lives in a village far from his castle. Nod gets seriously sick and is on the verge of death. Benjamin orders his subordinate Red to bring good medicine for him as soon as possible. However, there is no road from the castle to the village. Therefore, Red needs to climb over mountains and across canyons to reach the village. He has decided to get to the village on the shortest path on a map, that is, he will move on the straight line between the castle and the village. Then his way can be considered as polyline with n points (x1, y1)... (xn, yn) as illustlated in the following figure.

Here, xi and yi are coordinates of point i. The castle is located on the point (x1, y1), and the village is located on the point (xn, yn). Red can walk with speed vw. Also, since he has a skill to cut a tunnel through a mountain horizontally, he can move strictly inside the mountain with speed vc. Your job is to write a program to find the minimum time to get to the village.
Input
The input is given in the following format: n vw vc x1 y1 ... xn yn You may assume all the following: 1 ≤ n ≤ 1000, 1 ≤ vw, vc ≤ 10, -10000 ≤ xi, yi ≤ 10000, and xi < xj for all i < j.
Output
You should print the minimum time required to get to the village in a line. Each minimum time should be given as a decimal with an arbitrary number of fractional digits and with an absolute error of at most 10-6.
Example(s)
sample input
sample output
3
2 1
0 0
50 50
100 0
70.710678

sample input
sample output
3
1 1
0 0
50 50
100 0
100.000000

sample input
sample output
3
1 2
0 0
50 50
100 0
50.000000

sample input
sample output
3
2 1
0 0
100 100
150 50
106.066017

sample input
sample output
6
1 2
0 0
50 50
100 0
150 0
200 50
250 0
150.000000

sample input
sample output
2
1 2
0 0
100 0
100.000000

<|response|>
1. Abridged Problem Statement  
We have n points (x1,y1),…,(xn,yn) lying along Red’s straight-line route from the castle (point 1) to the village (point n). Between these boundary points, the path alternately lies above ground (on slopes) or strictly inside mountains. Red can  
• Walk along exposed slopes at speed vw, and  
• Tunnel horizontally inside mountains at speed vc.  
Compute the minimum time to travel from point 1 to point n along this polyline.

2. Key Observations  
• Dynamic Programming: let dp[i] = minimum time to reach boundary point i.  
• Two move-modes give two kinds of transitions:  
  - Slope walk from i−1 to i: time = distance(i−1,i)/vw.  
  - Horizontal tunnel: from some earlier boundary j to i, if the segment j→j+1 spans the same height yi. One walks along the slope j→I at speed vw, then tunnels horizontally I→i at speed vc.  
• To check a possible tunnel ending at i from j< i: the horizontal line y=yi must lie between min(yj,yj+1) and max(yj,yj+1). Compute the intersection point I of y=yi on segment j→j+1.  
• Symmetrically, tunnels can start at i and end at a later boundary k> i; this updates dp[k] using dp[i].  
• Early break: when scanning left from i, as soon as yj ≤ yi, the path has descended below yi and no further leftward segments can contain yi. Similarly for rightward scan.

3. Full Solution Approach  
Initialize dp[0]=0 and dp[i]=∞ for i>0. Process boundary points in order i=0…n−1:  
 A. Walk transition  
   if i>0,  
       dp[i] = min(dp[i], dp[i−1] + dist(points[i−1],points[i]) / vw)  
 B. Tunnel-in transitions (j from i−1 down to 0)  
   For each j from i−1 down to 0:  
     let (xj,yj) = point j and (xj1,yj1) = point j+1  
     if yi lies between yj and yj1:  
       compute intersection I = (xI, yi) on segment j→j+1  
       walk time d1 = distance((xj,yj),I)/vw  
       tunnel time d2 = |xi − xI|/vc  
       dp[i] = min(dp[i], dp[j] + d1 + d2)  
     if yj ≤ yi, break the j-loop  
 C. Tunnel-out transitions (k from i+1 up to n−1)  
   For each k from i+1 to n−1:  
     let (xk,yk) = point k and (xkm,ykm) = point k−1  
     if yi lies between ykm and yk:  
       compute intersection I = (xI, yi) on segment k−1→k  
       walk time d1 = distance(I,(xk,yk)) / vw  
       tunnel time d2 = |xI − xi| / vc  
       dp[k] = min(dp[k], dp[i] + d1 + d2)  
     if yk ≤ yi, break the k-loop  

Answer = dp[n−1]. Overall O(n²), which is fine for n≤1000.

4. C++ Implementation with Detailed Comments  
```cpp
#include <bits/stdc++.h>
using namespace std;

// Compute Euclidean distance between two points
double dist(double x1, double y1, double x2, double y2) {
    double dx = x1 - x2, dy = y1 - y2;
    return sqrt(dx*dx + dy*dy);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    double vw, vc;
    cin >> n >> vw >> vc;

    vector<double> x(n), y(n);
    for(int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
    }

    const double INF = 1e18;
    vector<double> dp(n, INF);
    dp[0] = 0.0;

    for(int i = 0; i < n; i++) {
        // A) Walk from i-1 to i on slope
        if(i > 0) {
            double d = dist(x[i], y[i], x[i-1], y[i-1]);
            dp[i] = min(dp[i], dp[i-1] + d / vw);
        }

        // B) Tunnel in: from any j<i whose segment covers y[i]
        for(int j = i-1; j >= 0; j--) {
            double yj = y[j], yj1 = y[j+1];
            // Check if horizontal line y=y[i] intersects segment j->j+1
            double lo = min(yj, yj1), hi = max(yj, yj1);
            if(y[i] < lo || y[i] > hi) {
                if(yj <= y[i]) break;
                else continue;
            }
            // Compute x-coordinate of intersection I at height y[i]
            double xI;
            if(fabs(yj1 - yj) < 1e-12) {
                // horizontal segment => choose endpoint
                xI = x[j+1];
            } else {
                double t = (y[i] - yj) / (yj1 - yj);
                xI = x[j] + t * (x[j+1] - x[j]);
            }
            // Walk j->I on slope, then tunnel I->i horizontally
            double d1 = dist(x[j], yj, xI, y[i]);
            double d2 = fabs(x[i] - xI);
            dp[i] = min(dp[i], dp[j] + d1 / vw + d2 / vc);

            // If segment start dropped below y[i], no more tunnels leftward
            if(yj <= y[i]) break;
        }

        // C) Tunnel out: from i to any k>i whose segment covers y[i]
        for(int k = i+1; k < n; k++) {
            double ykm = y[k-1], yk = y[k];
            double lo = min(ykm, yk), hi = max(ykm, yk);
            if(y[i] < lo || y[i] > hi) {
                if(yk <= y[i]) break;
                else continue;
            }
            double xI;
            if(fabs(yk - ykm) < 1e-12) {
                xI = x[k-1];
            } else {
                double t = (y[i] - ykm) / (yk - ykm);
                xI = x[k-1] + t * (x[k] - x[k-1]);
            }
            // Tunnel i->I then walk I->k
            double d2 = fabs(xI - x[i]);
            double d1 = dist(xI, y[i], x[k], yk);
            dp[k] = min(dp[k], dp[i] + d2 / vc + d1 / vw);

            if(yk <= y[i]) break;
        }
    }

    cout << fixed << setprecision(10) << dp[n-1] << "\n";
    return 0;
}
```

5. Python Implementation with Detailed Comments  
```python
import sys, math

def main():
    data = sys.stdin.read().split()
    it = iter(data)
    n = int(next(it))
    vw = float(next(it))
    vc = float(next(it))
    pts = [(float(next(it)), float(next(it))) for _ in range(n)]

    INF = 1e18
    dp = [INF]*n
    dp[0] = 0.0

    for i in range(n):
        xi, yi = pts[i]

        # A) Walk from i-1 to i
        if i > 0:
            x0, y0 = pts[i-1]
            d = math.hypot(xi - x0, yi - y0)
            dp[i] = min(dp[i], dp[i-1] + d/vw)

        # B) Tunnel in from any j<i
        for j in range(i-1, -1, -1):
            xj, yj = pts[j]
            xj1, yj1 = pts[j+1]
            lo, hi = min(yj, yj1), max(yj, yj1)
            if yi < lo or yi > hi:
                if yj <= yi: break
                else: continue
            # Intersection I on segment j->j+1 at height yi
            if abs(yj1 - yj) < 1e-12:
                xI = xj1
            else:
                t = (yi - yj)/(yj1 - yj)
                xI = xj + t*(xj1 - xj)
            # Walk then tunnel
            d1 = math.hypot(xI - xj, yi - yj)
            d2 = abs(xi - xI)
            dp[i] = min(dp[i], dp[j] + d1/vw + d2/vc)
            if yj <= yi: break

        # C) Tunnel out to any k>i
        for k in range(i+1, n):
            xkm, ykm = pts[k-1]
            xk, yk = pts[k]
            lo, hi = min(ykm, yk), max(ykm, yk)
            if yi < lo or yi > hi:
                if yk <= yi: break
                else: continue
            if abs(yk - ykm) < 1e-12:
                xI = xkm
            else:
                t = (yi - ykm)/(yk - ykm)
                xI = xkm + t*(xk - xkm)
            d2 = abs(xI - xi)
            d1 = math.hypot(xk - xI, yk - yi)
            dp[k] = min(dp[k], dp[i] + d2/vc + d1/vw)
            if yk <= yi: break

    # Print minimum time to reach last point
    print(f"{dp[n-1]:.10f}")

if __name__ == "__main__":
    main()
```