結果
| 問題 |
No.2805 Go to School
|
| コンテスト | |
| ユーザー |
maeshun
|
| 提出日時 | 2024-07-13 16:15:08 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,796 bytes |
| コンパイル時間 | 3,996 ms |
| コンパイル使用メモリ | 257,600 KB |
| 実行使用メモリ | 23,196 KB |
| 最終ジャッジ日時 | 2025-04-09 15:41:34 |
| 合計ジャッジ時間 | 11,165 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 35 WA * 1 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i, n) for(int i=0;i<(n);++i)
#define rep1(i, n) for(int i=1;i<=(n);i++)
#define ll long long
using mint = modint998244353;
using P = pair<ll,ll>;
using lb = long double;
using T = tuple<ll, ll, ll>;
#ifdef LOCAL
# include <debug_print.hpp>
# define dbg(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__)
#else
# define dbg(...) (static_cast<void>(0))
#endif
int main()
{
int n, m, l, s, e;
cin >> n >> m >> l >> s >> e;
vector<vector<P>> g(n);
rep(i,m) {
int a, b, t;
cin >> a >> b >> t;
--a;--b;
g[a].emplace_back(b, t);
g[b].emplace_back(a, t);
}
vector<int> t(l);
rep(i,l) cin >> t[i];
rep(i,l) --t[i];
const ll INF = 1e18;
vector<ll> dist(n, INF), rdist(n, INF);
dist[0] = 0;
rdist[n-1] = 0;
priority_queue<P, vector<P>, greater<P>> pq;
pq.emplace(0, 0);
while(!pq.empty()) {
auto [d, u] = pq.top();pq.pop();
if(dist[u]!=d) continue;
for(auto [v, c] : g[u]) {
if(dist[v]>dist[u] + c) {
dist[v] = dist[u] + c;
pq.emplace(dist[v], v);
}
}
}
pq.emplace(0, n-1);
while(!pq.empty()) {
auto [d, u] = pq.top();pq.pop();
if(rdist[u]!=d) continue;
for(auto [v, c] : g[u]) {
if(rdist[v]>rdist[u] + c) {
rdist[v] = rdist[u] + c;
pq.emplace(rdist[v], v);
}
}
}
ll ans = INF;
dbg(dist, rdist);
rep(i,l) {
if(dist[t[i]]<=s+e) {
ans = min(ans, max((ll)s, dist[t[i]])+1+rdist[t[i]]);
}
}
if(ans==INF) ans = -1;
cout << ans << endl;
return 0;
}
maeshun