Language: C++

#include <cstdio>
#include <cstring>
#include <map>
#include <queue>
#include <algorithm>
#define M INT_MAX
#define ll long long
#define P pair<ll,ll>
#define f first
#define s second
using namespace std;
ll m, n, u, v, d, c;
struct edge {
    ll v, d, c;
    edge(ll vv = 0, ll dd = M, ll cc = M): v(vv), d(dd), c(cc) {}
};
#define PP pair<P, ll>
vector<edge> node[10005];
bool use[10005];
P dist[10005];
int main() {
    while ((~scanf("%lld %lld", &n, &m)) && m && n) {
        for (int i = 0; i <= n; ++i) node[i].clear();
        for (int i = 0; i < m; ++i) {
            scanf("%lld %lld %lld %lld", &u, &v, &d, &c);
            node[u].push_back(edge(v, d, c));
            node[v].push_back(edge(u, d, c));
        }
        priority_queue<PP, vector<PP>, greater<PP > > pq;
        pq.push(PP(P(0, 0), 1));
        for (int i = 2; i <= n; ++i) dist[i].f = dist[i].s = M;
        dist[1].f = dist[1].s = 0;
        memset(use, 0, sizeof use);
        long long ans = 0;
        while (!pq.empty()) {
            ll u = pq.top().s, dd = pq.top().f.f, cc = pq.top().f.s;
            pq.pop();
            use[u] = true;
            if (dist[u].f < dd || (dist[u].f == dd && dist[u].s < cc)) continue;
            //printf("%d---%d---%d\n", u, dist[u].f, dist[u].s);
            for (int i = 0; i < node[u].size(); ++i) {
                ll v = node[u][i].v, d = node[u][i].d, c = node[u][i].c;
                if (!use[v] && (dist[v].f > d + dist[u].f
                                || dist[v].f == d + dist[u].f && dist[v].s > c)) {
                    dist[v].s = c;
                    dist[v].f = d + dist[u].f;
                    pq.push(PP(dist[v], v));
                }
            }
        }
        for (int i = 1; i <= n; ++i) ans += dist[i].s;
        printf("%lld\n", ans);
    }
    return 0;
}



Compiler output:
a.cc:6:11: error: 'INT_MAX' was not declared in this scope
    6 | #define M INT_MAX
      |           ^~~~~~~
a.cc:15:29: note: in expansion of macro 'M'
   15 |     edge(ll vv = 0, ll dd = M, ll cc = M): v(vv), d(dd), c(cc) {}
      |                             ^
a.cc:6:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    5 | #include <algorithm>
  +++ |+#include <climits>
    6 | #define M INT_MAX
a.cc:6:11: error: 'INT_MAX' was not declared in this scope
    6 | #define M INT_MAX
      |           ^~~~~~~
a.cc:15:40: note: in expansion of macro 'M'
   15 |     edge(ll vv = 0, ll dd = M, ll cc = M): v(vv), d(dd), c(cc) {}
      |                                        ^
a.cc:6:11: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    6 | #define M INT_MAX
      |           ^~~~~~~
a.cc:15:40: note: in expansion of macro 'M'
   15 |     edge(ll vv = 0, ll dd = M, ll cc = M): v(vv), d(dd), c(cc) {}
      |                                        ^
a.cc: In function 'int main()':
a.cc:6:11: error: 'INT_MAX' was not declared in this scope
    6 | #define M INT_MAX
      |           ^~~~~~~
a.cc:31:62: note: in expansion of macro 'M'
   31 |         for (int i = 2; i <= n; ++i) dist[i].f = dist[i].s = M;
      |                                                              ^
a.cc:6:11: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    6 | #define M INT_MAX
      |           ^~~~~~~
a.cc:31:62: note: in expansion of macro 'M'
   31 |         for (int i = 2; i <= n; ++i) dist[i].f = dist[i].s = M;
      |                                                              ^