#include #include #include #include #include #include using namespace std; struct road { int fr, to; double len, v1, v2; }; struct pos { int i; double t; pos(int _i, double _t): i(_i), t(_t) {} }; bool operator <(pos a, pos b) { return a.t > b.t; } double t_switch; double t_on_road(road r, double t_start) { double d_switch = (t_switch - t_start) * r.v1; if ( d_switch>=r.len ) return r.len / r.v1; if ( d_switch<=0 ) return r.len / r.v2; return d_switch / r.v1 + (r.len - d_switch) / r.v2; } int main() { int n, m; cin >> n >> m >> t_switch; vector roads(m); vector> adj(n+1); for(int i=0; i> r.fr >> r.to >> r.len >> r.v1 >> r.v2; roads[i] = r; adj[r.fr].push_back(r); swap(r.fr, r.to); adj[r.fr].push_back(r); } vector dist(n+1, -1); priority_queue q; q.push(pos(1, 0)); while ( !q.empty() ) { pos p = q.top(); q.pop(); if ( dist[p.i]>=0 ) continue; dist[p.i] = p.t; for(road r : adj[p.i]) { pos next(r.to, p.t + t_on_road(r, p.t)); q.push(next); } } cout << setprecision(15) << dist[n] << endl; return 0; }