Language: C++

#include"bits/stdc++.h"
using namespace std;
using ll = long long;



int n, m;
int s, g;

struct Edge {
    int to, dist, c;
    Edge(int to, int dist, int c) {
        this->to = to;
        this->dist = dist;
        this->c = c;
    }
};

struct Elem {
    int d, p, v;
    Elem(int d, int p, int v) {
        this->d = d;
        this->p = p;
        this->v = v;
    }

    bool operator < (const Elem& rhs) const {
        return this->d > rhs.d;
    }
};


double d[31][31];
vector<Edge> G[31];

void dijkstra(int s, int v) {
    priority_queue<Elem> que;
    memset(d, "0x3f", sizeof(d));
    d[s][v] = 0;
    que.push(Elem(0, s, v));
    while (!que.empty()) {
        Elem point = que.top(); que.pop();
        int x = point.p;
        int velo = point.v;
        if (d[x][velo] < point.d) {
            continue;
        }

        for (int i = 0; i < G[x].size(); i++) {
            Edge e = G[v][i];
            //加速
            if (e.c >= point.v + 1) {
                if (d[e.to][point.v + 1] > point.d + e.dist / (point.v + 1)) {
                    d[e.to][point.v + 1] = point.d + e.dist / (point.v + 1);
                    que.push(Elem(d[e.to][point.v + 1], e.to, point.v + 1));
                }
            }
            //等速
            if (e.c >= point.v && point.v>0) {
                if (d[e.to][point.v] > point.d + e.dist / (point.v)) {
                    d[e.to][point.v] = point.d + e.dist / (point.v);
                    que.push(Elem(d[e.to][point.v], e.to, point.v));
                }

            }
            //減速
            if (e.c >= point.v - 1 && point.v-1 > 0) {
                if (d[e.to][point.v -1] > point.d + e.dist / (point.v - 1)) {
                    d[e.to][point.v - 1] = point.d + e.dist / (point.v - 1);
                    que.push(Elem(d[e.to][point.v - 1], e.to, point.v - 1));
                }
            }

        }
    }
}

int main() {
        
    while (cin >> n >> m >> s >> g, n) {
        vector<Edge>vec[31];
        for (int i = 0; i < 31; i++)G[i].clear();

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

        dijkstra(0, 1);


        double ans = 1123456789;
        for (int i = 0; i <= 30; i++) {
            if (ans > d[g][i]&&d[g][i]!=0)ans = d[g][i];
        }
        
        if (ans == 1123456789) {
            cout << "unreachable" << endl;
        }else cout << fixed << setprecision(10) << ans << endl;


    }


}


Compiler output:
a.cc: In function 'void dijkstra(int, int)':
a.cc:38:15: error: invalid conversion from 'const char*' to 'int' [-fpermissive]
   38 |     memset(d, "0x3f", sizeof(d));
      |               ^~~~~~
      |               |
      |               const char*
In file included from /usr/include/c++/14/cstring:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121,
                 from a.cc:1:
/usr/include/string.h:61:37: note:   initializing argument 2 of 'void* memset(void*, int, size_t)'
   61 | extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1));
      |                                 ~~~~^~~