Problem p00546 (C++)

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

#define int long long int
#define rep(a, b, c) for (int a = b; a < c; a++)
#define repm(a, b, c) for (int a = (b - 1); a >= c; a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d", &a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()

using namespace std;

const int INF = 1e18 + 9;
const int Mod = 1e9 + 7;
inline int replac(str s) {
  double ans = 0;
  rep(i, 0, s.length()) { ans += (s[i] - '0') * pow(10, s.length() - i - 1); }
  return (int)ans;
}
inline string numstr(int m) {
  str s = "";
  while (m > 0) {
    char c;
    int a = m / 10;
    if (a > 0)
      a = m % (a * 10);
    else
      a = m;
    c = (char)('0' + a);
    s += c;
    m /= 10;
  }
  str st = "";
  for (int i = s.size() - 1; i >= 0; i--) {
    st += s[i];
  }
  return st;
}
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
vector<int> load[100001];
vi lo[100001];
vi ki;
int kiki[100001];
int cost[100001];
///(A->to)=cost
struct edge {
  int to, cost;
};
/// pii//first...???????????¢///second...????????????
int V;
const int MAX_V = 100001; //?¶??????°!!
vector<edge> G[MAX_V];
int d[MAX_V];

void dijkstra(int s) {
  priority_queue<pii, vector<pii>, greater<pii>> que;
  rep(i, 0, MAX_V) d[i] = INF;
  d[s] = 0;
  que.push(pii(0, s));
  while (!que.empty()) {
    pii p = que.top();
    que.pop();
    int v = p.second;
    if (d[v] < p.first)
      continue;
    rep(i, 0, G[v].size()) {
      edge e = G[v][i];
      // cout << "c" << d[e.to] << " " << d[v]+e.cost << endl;
      if (d[e.to] > d[v] + e.cost) {
        d[e.to] = d[v] + e.cost;
        que.push(pii(d[e.to], e.to));
      }
    }
  }
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  rep(i, 0, 100001) {
    cost[i] = 0;
    kiki[i] = 0;
  }
  int n, m, k, s;
  cin >> n >> m >> k >> s;
  int pco, qco;
  cin >> pco >> qco;
  rep(j, 0, k) {
    int c;
    cin >> c;
    ki.pb(c);
    kiki[c] = 1;
  }
  rep(i, 0, m) {
    int x, y;
    cin >> x >> y;
    if (!kiki[y])
      load[x].pb(y);
    if (!kiki[x])
      load[y].pb(x);
  }
  queue<pii> que;
  for (int v : ki) {
    // cout << v << endl;
    bool used[100001] = {false};
    cost[v] = INF;
    que.push(mp(v, s));
    while (!que.empty()) {
      pii q = que.front();
      que.pop();
      int pla = q.first;
      int num = q.second;
      // if(used[pla])continue;
      // used[pla]=true;
      for (int va : load[pla]) {
        //    cout << pla<<"<-"<<va << endl;
        if (cost[va] != INF)
          cost[va] = qco;
        if ((num - 1) > 0)
          que.push(mp(va, num - 1));
      }
    }
  }
  rep(i, 1, n + 1) {
    if (cost[i] == 0)
      cost[i] = pco;
    //   cout << i << "="<< cost[i] << endl;
  }

  rep(i, 1, n + 1) {
    rep(j, 0, load[i].size()) {
      int a = load[i][j];
      if (cost[a] == INF)
        continue;
      edge e;
      e.to = a;
      e.cost = cost[a];
      G[i].pb(e);
      // cout << e.to << "<-" <<  i << "=" <<e.cost << endl;
    }
  }
  dijkstra(1);
  cout << d[n] - cost[n] << endl;
  return 0;
}

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

#define int long long int
#define rep(a, b, c) for (int a = b; a < c; a++)
#define repm(a, b, c) for (int a = (b - 1); a >= c; a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d", &a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()

using namespace std;

const int INF = 1e18 + 9;
const int Mod = 1e9 + 7;
inline int replac(str s) {
  double ans = 0;
  rep(i, 0, s.length()) { ans += (s[i] - '0') * pow(10, s.length() - i - 1); }
  return (int)ans;
}
inline string numstr(int m) {
  str s = "";
  while (m > 0) {
    char c;
    int a = m / 10;
    if (a > 0)
      a = m % (a * 10);
    else
      a = m;
    c = (char)('0' + a);
    s += c;
    m /= 10;
  }
  str st = "";
  for (int i = s.size() - 1; i >= 0; i--) {
    st += s[i];
  }
  return st;
}
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
vector<int> load[100001];
vi lo[100001];
vi ki;
int kiki[100001];
int cost[100001];
///(A->to)=cost
struct edge {
  int to, cost;
};
/// pii//first...???????????¢///second...????????????
int V;
const int MAX_V = 100001; //?¶??????°!!
vector<edge> G[MAX_V];
int d[MAX_V];

void dijkstra(int s) {
  priority_queue<pii, vector<pii>, greater<pii>> que;
  rep(i, 0, MAX_V) d[i] = INF;
  d[s] = 0;
  que.push(pii(0, s));
  while (!que.empty()) {
    pii p = que.top();
    que.pop();
    int v = p.second;
    if (d[v] < p.first)
      continue;
    rep(i, 0, G[v].size()) {
      edge e = G[v][i];
      // cout << "c" << d[e.to] << " " << d[v]+e.cost << endl;
      if (d[e.to] > d[v] + e.cost) {
        d[e.to] = d[v] + e.cost;
        que.push(pii(d[e.to], e.to));
      }
    }
  }
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  rep(i, 0, 100001) {
    cost[i] = 0;
    kiki[i] = 0;
  }
  int n, m, k, s;
  cin >> n >> m >> k >> s;
  int pco, qco;
  cin >> pco >> qco;
  rep(j, 0, k) {
    int c;
    cin >> c;
    ki.pb(c);
    kiki[c] = 1;
  }
  rep(i, 0, m) {
    int x, y;
    cin >> x >> y;
    if (!kiki[y])
      load[x].pb(y);
    if (!kiki[x])
      load[y].pb(x);
  }
  queue<pii> que;
  for (int v : ki) {
    // cout << v << endl;
    bool used[100001] = {false};
    cost[v] = INF;
    que.push(mp(v, s));
    while (!que.empty()) {
      pii q = que.front();
      que.pop();
      int pla = q.first;
      int num = q.second;
      if (used[pla])
        continue;
      used[pla] = true;
      for (int va : load[pla]) {
        //    cout << pla<<"<-"<<va << endl;
        if (cost[va] != INF)
          cost[va] = qco;
        if ((num - 1) > 0)
          que.push(mp(va, num - 1));
      }
    }
  }
  rep(i, 1, n + 1) {
    if (cost[i] == 0)
      cost[i] = pco;
    //   cout << i << "="<< cost[i] << endl;
  }

  rep(i, 1, n + 1) {
    rep(j, 0, load[i].size()) {
      int a = load[i][j];
      if (cost[a] == INF)
        continue;
      edge e;
      e.to = a;
      e.cost = cost[a];
      G[i].pb(e);
      // cout << e.to << "<-" <<  i << "=" <<e.cost << endl;
    }
  }
  dijkstra(1);
  cout << d[n] - cost[n] << endl;
  return 0;
}