Language: C++

#include <iostream>
#include <queue>
#include <vector>
using namespace std;

class Node {
public:
  int pre;
  int now;
  int vel;
  double time;

  Node(int p, int n, int v, double t) {
    pre = p;
    now = n;
    vel = v;
    time = t;
  }

  bool operator<(const Node &n) const {
    return time > n.time;
  }
};

int main() {
  while (true) {
    int n, m;
    cin >> n >> m;

    if (n == 0) {
      break;
    }

    int s, g;
    cin >> s >> g;

    vector<vector<int> > d(n + 1), c(n + 1);
    for (int i = 0; i <= n; i++) {
      d[i].resize(n + 1);
      c[i].resize(n + 1);
      fill(d[i].begin(), d[i].end(), -1);
      fill(c[i].begin(), c[i].end(), 0);
    }

    for (int i = 0; i < m; i++) {
      int x, y;
      cin >> x >> y;
      cin >> d[x][y] >> c[x][y];
      d[y][x] = d[x][y];
      c[y][x] = c[x][y];
    }

    bool f[31][31][31];
    for (int i = 0; i < 31; i++) {
      for (int j = 0; j < 31; j++) {
	for (int k = 0; k < 31; k++) {
	  f[i][j][k] = false;
	}
      }
    }
  
    bool goal = false;
    Node snd(0, s, 0, 0.0);
    priority_queue<Node, vector<Node>, greater<Node> > q;
    q.push(snd);
    while (!q.empty()) {
      Node nd = q.top();
      q.pop();
      if (nd.now == g && nd.vel == 1) {
	goal = true;
	cout << nd.time << endl;
	break;
      }
      if (f[nd.pre][nd.now][nd.vel]) {
	continue;
      }
      f[nd.pre][nd.now][nd.vel] = true;
      for (int i = 1; i <= n; i++) {
	if (i != nd.pre && d[nd.now][i] != -1) {
	  for (int j = -1; j <= 1; j++) {
	    int vel = nd.vel + j;
	    if (vel > 0 && vel <= c[nd.now][i]) {
	      Node next(nd.now, i, vel, nd.time + (double)d[nd.now][i] / vel);
	      q.push(next);
	    }
	  }
	}
      }
    }

    if (!goal) {
      cout << "unreachable" << endl;
    }
  }

  return 0;
}

Compiler output:
In file included from /usr/include/c++/14/string:49,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_function.h: In instantiation of 'constexpr bool std::greater<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = Node]':
/usr/include/c++/14/bits/predefined_ops.h:196:23:   required from 'bool __gnu_cxx::__ops::_Iter_comp_val<_Compare>::operator()(_Iterator, _Value&) [with _Iterator = __gnu_cxx::__normal_iterator<Node*, std::vector<Node> >; _Value = Node; _Compare = std::greater<Node>]'
  196 |         { return bool(_M_comp(*__it, __val)); }
      |                       ~~~~~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_heap.h:140:48:   required from 'void std::__push_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<Node*, vector<Node> >; _Distance = long int; _Tp = Node; _Compare = __gnu_cxx::__ops::_Iter_comp_val<greater<Node> >]'
  140 |       while (__holeIndex > __topIndex && __comp(__first + __parent, __value))
      |                                          ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_heap.h:216:23:   required from 'void std::push_heap(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<Node*, vector<Node> >; _Compare = greater<Node>]'
  216 |       std::__push_heap(__first, _DistanceType((__last - __first) - 1),
      |       ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  217 |                        _DistanceType(0), _GLIBCXX_MOVE(__value), __cmp);
      |                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:739:16:   required from 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = Node; _Sequence = std::vector<Node>; _Compare = std::greater<Node>; value_type = Node]'
  739 |         std::push_heap(c.begin(), c.end(), comp);
      |         ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:65:11:   required from here
   65 |     q.push(snd);
      |     ~~~~~~^~~~~
/usr/include/c++/14/bits/stl_function.h:395:20: error: no match for 'operator>' (operand types are 'const Node' and 'const Node')
  395 |       { return __x > __y; }
      |                ~~~~^~~~~
In file included from /usr/include/c++/14/string:48:
/usr/include/c++/14/bits/stl_iterator.h:462:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator>(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
  462 |     operator>(const reverse_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:462:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_function.h:395:20: note:   'const Node' is not derived from 'const std::reverse_iterator<_Iterator>'
  395 |       { return __x > __y; }
      |                ~~~~^~~~~
/usr/include/c++/14/bits/stl_iterator.h:507:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator>(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
  507 |     operator>(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:507:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_function.h:395:20: note:   'const Node' is not derived from 'const std::reverse_iterator<_Iterator>'
  395 |       { return __x > __y; }
      |                ~~~~^~~~~
/usr/include/c++/14/bits/stl_iterator.h:1714:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator>(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
 1714 |     operator>(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1714:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_function.h:395:20: note:   'const Node' is not derived from 'const std::move_iterator<_IteratorL>'
  395 |       { return __x > __y; }
      |                ~~~~^~~~~
/usr/include/c++/14/bits/stl_iterator.h:1774:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator>(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
 1774 |     operator>(const move_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1774:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_function.h:395:20: note:   'const Node' is not derived from 'const std::move_iterator<_IteratorL>'
  395 |       { return __x > __y; }
      |                ~~~~^~~~~