結果

問題 No.2805 Go to School
ユーザー keisuke6keisuke6
提出日時 2024-07-01 14:06:19
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,357 bytes
コンパイル時間 2,324 ms
コンパイル使用メモリ 217,088 KB
実行使用メモリ 22,968 KB
最終ジャッジ日時 2024-07-04 21:13:42
合計ジャッジ時間 8,993 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 WA -
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 118 ms
9,088 KB
testcase_10 AC 351 ms
21,116 KB
testcase_11 AC 220 ms
14,220 KB
testcase_12 AC 309 ms
17,188 KB
testcase_13 AC 47 ms
6,940 KB
testcase_14 WA -
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 162 ms
10,880 KB
testcase_18 AC 104 ms
8,704 KB
testcase_19 AC 266 ms
14,916 KB
testcase_20 AC 343 ms
18,772 KB
testcase_21 AC 155 ms
11,776 KB
testcase_22 AC 247 ms
14,648 KB
testcase_23 AC 242 ms
14,044 KB
testcase_24 AC 62 ms
8,896 KB
testcase_25 WA -
testcase_26 AC 184 ms
16,972 KB
testcase_27 AC 16 ms
6,944 KB
testcase_28 AC 28 ms
7,552 KB
testcase_29 AC 103 ms
13,276 KB
testcase_30 AC 151 ms
10,880 KB
testcase_31 AC 248 ms
18,936 KB
testcase_32 AC 232 ms
18,216 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 120 ms
9,600 KB
testcase_36 AC 118 ms
9,984 KB
testcase_37 AC 212 ms
14,256 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
    int N,M,L,S,E;
    cin>>N>>M>>L>>S>>E;
    vector<vector<pair<int,int>>> G(N);
    for(int i=0;i<M;i++){
    	int a,b,c;
    	cin>>a>>b>>c;
    	a--;
    	b--;
    	G[a].push_back({b,c});
    	G[b].push_back({a,c});
    }
    set<int> T;
    for(int i=0;i<L;i++){
    	int a;
    	cin>>a;
    	T.insert(a-1);
    }
    vector<int> dist(N,1e18);
    dist[0] = 0;
    priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> pq;
    pq.push({0,0});
    while(!pq.empty()){
    	int u,w;
    	tie(w,u) = pq.top();
    	pq.pop();
    	if(dist[u] != w) continue;
    	for(auto [v,x]:G[u])if(dist[v] > w+x){
    		dist[v] = w+x;
    		pq.push({dist[v],v});
    	}
    }
    for(int i=0;i<N-1;i++){
    	dist[i] = max(dist[i],S);
    	if(S <= dist[i] && dist[i] < S+E && T.count(i)){
    		pq.push({dist[i],i});
    	}
    	else{
    		dist[i] = 1e18;
    	}
    }
    if(dist[N-1] >= S+E) dist[N-1] = 1e18;
    else{
    	cout<<dist[N-1]+(dist[N-1] > S)<<endl;
    	return 0;
    }
    while(!pq.empty()){
    	int u,w;
    	tie(w,u) = pq.top();
    	pq.pop();
    	if(dist[u] != w) continue;
    	for(auto [v,x]:G[u])if(dist[v] > w+x){
    		dist[v] = w+x;
    		pq.push({dist[v],v});
    	}
    }
    cout<<(dist[N-1]+1 > 1e17 ? -1 : dist[N-1]+1)<<endl;
}
0