Problem p00546 (C++) — buggy submission, verdict: Runtime Error

#define _USE_MATH_DEFINES
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <queue>
#include <set>
#include <vector>

#define LLD long long int
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep1(i, x) for (int i = 1; i <= x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (int i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long int INF = 1001001001001001001;
int N, M, K, S;
////////
int P, Q;
bool C[100002];
///////
const int MAX_V = 100002;
struct edge {
  int to, cost;
};
vector<edge> edges[MAX_V]; // V??????????????????
LLD d[MAX_V];              //???????????????????????¢

void dijkstra(int s) { //?§????s??????????????????????????????????±???????
  priority_queue<pair<LLD, int>, vector<pair<LLD, int>>,
                 greater<pair<LLD, int>>>
      que;
  memset(d, INF, sizeof(d)); // fill(d,d+V,INF);
  d[s] = 0;
  que.push(make_pair(0, s));

  while (!que.empty()) {
    pair<LLD, int> p = que.top();
    que.pop();
    int v = p.sc;
    int cst = 0; ////cst->e.cost
    if (d[v] < p.first)
      continue;
    if (v != s) {
      if (C[v])
        cst = Q;
      else
        cst = P;
    } ////special
    rep(i, edges[v].size()) {
      edge e = edges[v][i];
      if (d[e.to] > d[v] + cst) {
        d[e.to] = d[v] + cst;
        que.push(make_pair(d[e.to], e.to));
      }
    }
  }
}

vector<int> Ks;
int main() {
  // FILE *f;
  // f=fopen("C:\\\\Users\\\\Ray\\\\Desktop\\\\JOI?????????\\\\0623-in4.txt","r");
  scanf("%d %d %d %d", &N, &M, &K, &S);
  fill(C, C + N, false);

  scanf("%d %d", &P, &Q);

  queue<pair<int, int>> kiken;
  rep(i, K) {
    int k;
    scanf("%d", &k);
    k--;
    Ks.pb(k);
    kiken.push(mp(k, S));
  }

  rep(i, M) {
    int a, b;
    scanf("%d %d", &a, &b);
    a--;
    b--;
    edge e;
    e.to = b;
    e.cost = 0;
    edges[a].pb(e);
    e.to = a;
    e.cost = 0;
    edges[b].pb(e);
  }
  //??±?????????
  while (kiken.size()) {
    pair<int, int> p = kiken.front();
    kiken.pop();
    if (C[p.fr])
      continue;
    C[p.fr] = true;
    if (p.sc == 0)
      continue;
    rep(i, edges[p.fr].size()) { kiken.push(mp(edges[p.fr][i].to, p.sc - 1)); }
  }
  rep(i, K) {
    if (edges[Ks[i]].size())
      edges[Ks[i]].clear();
  }

  // dijkstra
  dijkstra(0);
  printf("%lld\\n", d[N - 1]);
}

Error: -11

Fixed submission:

#define _USE_MATH_DEFINES
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <queue>
#include <set>
#include <vector>

#define LLD long long int
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep1(i, x) for (int i = 1; i <= x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (int i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long int INF = 1001001001001001001;
int N, M, K, S;
////////
int P, Q;
bool C[100002];
///////
const int MAX_V = 100002;
struct edge {
  int to, cost;
};
vector<edge> edges[MAX_V]; // V??????????????????
LLD d[MAX_V];              //???????????????????????¢

void dijkstra(int s) { //?§????s??????????????????????????????????±???????
  priority_queue<pair<LLD, int>, vector<pair<LLD, int>>,
                 greater<pair<LLD, int>>>
      que;
  memset(d, INF, sizeof(d)); // fill(d,d+V,INF);
  d[s] = 0;
  que.push(make_pair(0, s));

  while (!que.empty()) {
    pair<LLD, int> p = que.top();
    que.pop();
    int v = p.sc;
    int cst = 0; ////cst->e.cost
    if (d[v] < p.first)
      continue;
    if (v != s) {
      if (C[v])
        cst = Q;
      else
        cst = P;
    } ////special
    rep(i, edges[v].size()) {
      edge e = edges[v][i];
      if (d[e.to] > d[v] + cst) {
        d[e.to] = d[v] + cst;
        que.push(make_pair(d[e.to], e.to));
      }
    }
  }
}

vector<int> Ks;
int main() {
  FILE *f;
  f = fopen("C:\\\\Users\\\\Ray\\\\Desktop\\\\JOI?????????\\\\0623-in4.txt", "r");
  fscanf(f, "%d %d %d %d", &N, &M, &K, &S);
  fill(C, C + N, false);

  fscanf(f, "%d %d", &P, &Q);

  queue<pair<int, int>> kiken;
  rep(i, K) {
    int k;
    fscanf(f, "%d", &k);
    k--;
    Ks.pb(k);
    kiken.push(mp(k, S));
  }

  rep(i, M) {
    int a, b;
    fscanf(f, "%d %d", &a, &b);
    a--;
    b--;
    edge e;
    e.to = b;
    e.cost = 0;
    edges[a].pb(e);
    e.to = a;
    e.cost = 0;
    edges[b].pb(e);
  }
  //??±?????????
  while (kiken.size()) {
    pair<int, int> p = kiken.front();
    kiken.pop();
    if (C[p.fr])
      continue;
    C[p.fr] = true;
    if (p.sc == 0)
      continue;
    rep(i, edges[p.fr].size()) { kiken.push(mp(edges[p.fr][i].to, p.sc - 1)); }
  }
  rep(i, K) {
    if (edges[Ks[i]].size())
      edges[Ks[i]].clear();
  }

  // dijkstra
  dijkstra(0);
  printf("%lld\\n", d[N - 1]);
}