Problem p03305 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;
template <typename T>
using reversed_priority_queue =
    std::priority_queue<T, std::vector<T>, std::greater<T>>;

struct Edge {
  ll next, yen, snuuk;
};

const ll INF = ((ll)1) << 62;
const ll OFFSET = 1000000000000000ll;

vector<Edge> edges[200000];
vector<ll> c_yen(20000, INF);   // startからの円での距離
vector<ll> c_snuuk(20000, INF); // endからのsnuukでの距離

signed main() {
  ll N, M, S, T;
  cin >> N >> M >> S >> T;
  rep(i, M) {
    ll u, v, a, b;
    cin >> u >> v >> a >> b;
    edges[u].push_back({v, a, b});
    edges[v].push_back({u, a, b});
  }

  {
    reversed_priority_queue<PLL> q;
    q.push({0, S});
    while (!q.empty()) {
      ll v, yen;
      tie(yen, v) = q.top();
      q.pop();
      if (c_yen[v] <= yen)
        continue;
      c_yen[v] = yen;
      for (auto e : edges[v]) {
        q.push({yen + e.yen, e.next});
      }
    }
  }
  {
    reversed_priority_queue<PLL> q;
    q.push({0, T});
    while (!q.empty()) {
      ll v, snuuk;
      tie(snuuk, v) = q.top();
      q.pop();
      if (c_snuuk[v] <= snuuk)
        continue;
      c_snuuk[v] = snuuk;
      for (auto e : edges[v]) {
        q.push({snuuk + e.snuuk, e.next});
      }
    }
  }

  vector<ll> ans(N + 1);
  ll p = c_yen[N] + c_snuuk[N];
  ans[N - 1] = c_yen[N] + c_snuuk[N];
  for (ll i = N - 2; i >= 0; i--) {
    ans[i] = min(ans[i + 1], c_yen[i + 1] + c_snuuk[i + 1]);
  }

  rep(i, N) { printf("%lld\n", OFFSET - ans[i]); }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;
template <typename T>
using reversed_priority_queue =
    std::priority_queue<T, std::vector<T>, std::greater<T>>;

struct Edge {
  ll next, yen, snuuk;
};

const ll INF = ((ll)1) << 62;
const ll OFFSET = 1000000000000000ll;

vector<Edge> edges[200000];
vector<ll> c_yen(200000, INF);   // startからの円での距離
vector<ll> c_snuuk(200000, INF); // endからのsnuukでの距離

signed main() {
  ll N, M, S, T;
  cin >> N >> M >> S >> T;
  rep(i, M) {
    ll u, v, a, b;
    cin >> u >> v >> a >> b;
    edges[u].push_back({v, a, b});
    edges[v].push_back({u, a, b});
  }

  {
    reversed_priority_queue<PLL> q;
    q.push({0, S});
    while (!q.empty()) {
      ll v, yen;
      tie(yen, v) = q.top();
      q.pop();
      if (c_yen[v] <= yen)
        continue;
      c_yen[v] = yen;
      for (auto e : edges[v]) {
        q.push({yen + e.yen, e.next});
      }
    }
  }
  {
    reversed_priority_queue<PLL> q;
    q.push({0, T});
    while (!q.empty()) {
      ll v, snuuk;
      tie(snuuk, v) = q.top();
      q.pop();
      if (c_snuuk[v] <= snuuk)
        continue;
      c_snuuk[v] = snuuk;
      for (auto e : edges[v]) {
        q.push({snuuk + e.snuuk, e.next});
      }
    }
  }

  vector<ll> ans(N + 1);
  ll p = c_yen[N] + c_snuuk[N];
  ans[N - 1] = c_yen[N] + c_snuuk[N];
  for (ll i = N - 2; i >= 0; i--) {
    ans[i] = min(ans[i + 1], c_yen[i + 1] + c_snuuk[i + 1]);
  }

  rep(i, N) { printf("%lld\n", OFFSET - ans[i]); }
  return 0;
}