結果
問題 | No.2805 Go to School |
ユーザー |
![]() |
提出日時 | 2024-07-12 21:47:22 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 211 ms / 2,000 ms |
コード長 | 1,443 bytes |
コンパイル時間 | 2,030 ms |
コンパイル使用メモリ | 210,988 KB |
実行使用メモリ | 23,592 KB |
最終ジャッジ日時 | 2024-07-16 01:38:59 |
合計ジャッジ時間 | 6,379 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 35 |
ソースコード
#include<bits/stdc++.h>using namespace std;#define REP(i,n)for(int i=0;i<(n);++i)#define REP1(i,n)for(int i=1;i<=(n);++i)#define FORE(...)for(auto&&__VA_ARGS__)#define ALL(x)begin(x),end(x)#define mset(x,y)memset(x,y,sizeof x)#define pb push_back#define eb emplace_back#define V vector#define lb(x,y)(lower_bound(begin(x),end(x),y)-begin(x))#define ub(x,y)(upper_bound(begin(x),end(x),y)-begin(x))template<class T,class S>inline bool chmin(T&A,S B){return A>B?A=B,1:0;}template<class T,class S>inline bool chmax(T&A,S B){return A<B?A=B,1:0;}void fastIO(){ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}using Int=long long;using Real=long double;using PII=pair<int,int>;using PLL=pair<Int,Int>;constexpr Int INF=1001001001001001001LL;Int N,M,L,S,E;V<PLL>G[202020];bool T[202020];V<Int>dijkstra(Int s){V<Int>ret(N,INF);ret[s]=0;priority_queue<pair<Int,int>>Q;Q.push({0,s});while(!Q.empty()){auto[c,u]=Q.top();c=-c;Q.pop();if(ret[u]<c)continue;FORE([v,t]:G[u])if(chmin(ret[v],ret[u]+t)){Q.push({-ret[v],v});}}return ret;}int main(){fastIO();cin>>N>>M>>L>>S>>E;REP(i,M){Int a,b,t;cin>>a>>b>>t;--a;--b;G[a].eb(b,t);G[b].eb(a,t);}REP(i,L){int t;cin>>t;T[--t]=true;}auto se=dijkstra(0);auto mi=dijkstra(N-1);Int ans=INF;REP(i,N){if(T[i]&&se[i]<S+E){chmin(ans,mi[i]+max(S,se[i])+1);}}if(ans==INF)ans=-1;cout<<ans<<"\n";}