Problem p03305 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <array>
#include <cstdio>
#include <deque>
#include <queue>
#include <vector>

struct node {
  long long v, cost;
  node(long long v, long long cost) : v(v), cost(cost) {}
  bool operator<(const node &n) const { return cost > n.cost; }
};

int main() {
  long long n, m, s, t, tu, tv, ta, tb;
  scanf("%lld%lld%lld%lld", &n, &m, &s, &t);
  std::vector<long long> yen(n + 1, 1000000000001000),
      snuuk(n + 1, 1000000000001000);
  /* to, yen, snuuk */
  std::vector<std::deque<std::array<long long, 3>>> g(n + 1);
  for (long long i = 0; i < m; i++) {
    scanf("%lld%lld%lld%lld", &tu, &tv, &ta, &tb);
    g[tu].push_back({tv, ta, tb});
    g[tv].push_back({tu, ta, tb});
  }

  std::priority_queue<node> que;
  que.push(node(s, 0));
  while (!que.empty()) {
    long long v = que.top().v, c = que.top().cost;
    que.pop();
    if (yen[v] >= 0 && yen[v] <= c)
      continue;
    yen[v] = c;
    for (long long i = 0; i < g[v].size(); i++) {
      if (yen[g[v][i][0]] <= c + g[v][i][1])
        continue;
      que.push(node(g[v][i][0], c + g[v][i][1]));
    }
  }

  que.push(node(t, 0));
  while (!que.empty()) {
    long long v = que.top().v, c = que.top().cost;
    que.pop();
    if (snuuk[v] >= 0 && snuuk[v] <= c)
      continue;
    snuuk[v] = c;
    for (long long i = 0; i < g[v].size(); i++) {
      que.push(node(g[v][i][0], c + g[v][i][2]));
    }
  }

  long long mi[10010];
  for (long long i = 0; i < 10010; i++) {
    mi[i] = 1000000001000000;
  }

  for (long long i = n; i > 0; i--) {
    mi[i] = std::min(mi[i + 1], yen[i] + snuuk[i]);
  }

  for (long long i = 1; i <= n; i++) {
    printf("%lld\n", 1000000000000000 - mi[i]);
  }

  return 0;
}


Fixed submission:
#include <algorithm>
#include <array>
#include <cstdio>
#include <deque>
#include <queue>
#include <vector>

struct node {
  long long v, cost;
  node(long long v, long long cost) : v(v), cost(cost) {}
  bool operator<(const node &n) const { return cost > n.cost; }
};

int main() {
  long long n, m, s, t, tu, tv, ta, tb;
  scanf("%lld%lld%lld%lld", &n, &m, &s, &t);
  std::vector<long long> yen(n + 1, 1000000000001000),
      snuuk(n + 1, 1000000000001000);
  /* to, yen, snuuk */
  std::vector<std::deque<std::array<long long, 3>>> g(n + 1);
  for (long long i = 0; i < m; i++) {
    scanf("%lld%lld%lld%lld", &tu, &tv, &ta, &tb);
    g[tu].push_back({tv, ta, tb});
    g[tv].push_back({tu, ta, tb});
  }

  std::priority_queue<node> que;
  que.push(node(s, 0));
  while (!que.empty()) {
    long long v = que.top().v, c = que.top().cost;
    que.pop();
    if (yen[v] >= 0 && yen[v] <= c)
      continue;
    yen[v] = c;
    for (long long i = 0; i < g[v].size(); i++) {
      if (yen[g[v][i][0]] <= c + g[v][i][1])
        continue;
      que.push(node(g[v][i][0], c + g[v][i][1]));
    }
  }

  que.push(node(t, 0));
  while (!que.empty()) {
    long long v = que.top().v, c = que.top().cost;
    que.pop();
    if (snuuk[v] >= 0 && snuuk[v] <= c)
      continue;
    snuuk[v] = c;
    for (long long i = 0; i < g[v].size(); i++) {
      que.push(node(g[v][i][0], c + g[v][i][2]));
    }
  }

  long long mi[100010];
  for (long long i = 0; i < 100010; i++) {
    mi[i] = 1000000001000000;
  }

  for (long long i = n; i > 0; i--) {
    mi[i] = std::min(mi[i + 1], yen[i] + snuuk[i]);
  }

  for (long long i = 1; i <= n; i++) {
    printf("%lld\n", 1000000000000000 - mi[i]);
  }

  return 0;
}