結果
| 問題 | 
                            No.2805 Go to School
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2024-07-30 22:43:31 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,663 bytes | 
| コンパイル時間 | 2,121 ms | 
| コンパイル使用メモリ | 179,980 KB | 
| 実行使用メモリ | 17,836 KB | 
| 最終ジャッジ日時 | 2024-07-30 22:43:41 | 
| 合計ジャッジ時間 | 7,770 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 17 WA * 18 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define INF 1e9
struct Edge {
  int to;
  int dist;
  Edge(int to, int dist) : to(to), dist(dist) {}
  bool operator=(const Edge &rhs) const {
    return to == rhs.to;
  }
};
vector<int> dijkstra(int N, int s, vector<vector<Edge>> &graph) {
  vector<int> distance(N, INF);
  vector<int> from(N, -1);
  priority_queue<pair<int, int>,
		 vector<pair<int, int>>,
		 greater<pair<int, int>>> q;
  distance[s] = 0;
  q.push({0, s});
  while (!q.empty()) {
    pair<int, int> p = q.top();
    q.pop();
    int path_now = p.first;
    int p_now = p.second;
    if (distance[p_now] < path_now)
      continue;
    for (Edge e : graph[p_now]) {
      int path_new = path_now + e.dist;
      int p_new = e.to;
      if (path_new < distance[p_new]) {
	distance[p_new] = path_new;
	from[p_new] = p_now;
	q.push({path_new, p_new});
      }
    }
  }
  return distance;
}
int main() {
  int n, m, l, s, e;
  cin >> n >> m >> l >> s >> e;
  vector<vector<Edge>> g(n);
  rep(i, m) {
    int a, b, t;
    cin >> a >> b >> t;
    a--; b--;
    g[a].push_back(Edge(b, t));
    g[b].push_back(Edge(a, t));
  }
  vector<int> t(n, 0);
  rep(i, l) {
    int ti;
    cin >> ti;
    ti--;
    t[ti] = 1;
  }
  vector<int> d = dijkstra(n, 0, g);
  vector<int> id = dijkstra(n, n-1, g);
  int ans = INF;
  rep(i, n) {
    if (t[i] == 0)
      continue;
    if (d[i] >= s && d[i] <= s + e) {
      ans = d[n-1] + 1;
      break;
    }
    if (d[i] < s) {
      ans = min(s + 1 + id[i], ans);
    }
  }
  if (ans == INF)
    cout << -1 << endl;
  else
    cout << ans << endl;
  return 0;
}