結果
| 問題 |
No.2805 Go to School
|
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2024-07-12 21:17:30 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 386 ms / 2,000 ms |
| コード長 | 1,216 bytes |
| コンパイル時間 | 4,059 ms |
| コンパイル使用メモリ | 259,728 KB |
| 実行使用メモリ | 23,296 KB |
| 最終ジャッジ日時 | 2025-04-09 15:36:22 |
| 合計ジャッジ時間 | 11,342 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 36 |
ソースコード
#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 1000000000000000001
vector<long long> get(vector<vector<pair<int,long long>>> &G, int s){
int N = G.size();
vector<long long> d(N,Inf64);
d[s] = 0;
priority_queue<pair<long long,int>,vector<pair<long long,int>>,greater<pair<long long,int>>> pq;
pq.push({0,s});
while(!pq.empty()){
auto [c,v] = pq.top();
pq.pop();
if(d[v] < c) continue;
for(auto [u,w] : G[v]){
if(d[u] > d[v] + w){
d[u] = d[v] + w;
pq.push({d[u],u});
}
}
}
return d;
}
int main(){
int N,M,L,S,E;
cin>>N>>M>>L>>S>>E;
vector<vector<pair<int,long long>>> G(N);
rep(i,M){
int a,b;
long long c;
cin>>a>>b>>c;
a--,b--;
G[a].push_back({b,c});
G[b].push_back({a,c});
}
auto dx = get(G,0), dy = get(G,N-1);
long long ans = Inf64;
E += S;
rep(i,L){
long long t;
cin>>t;
t--;
long long d0 = dx[t];
if(d0 >= E)continue;
if(dy[t]==Inf64)continue;
d0 = max(d0,(long long)S);
ans = min(ans,d0+1+dy[t]);
}
if(ans==Inf64)ans = -1;
cout<<ans<<endl;
return 0;
}
沙耶花