結果

問題 No.2805 Go to School
ユーザー kotatsugamekotatsugame
提出日時 2024-07-12 21:20:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 282 ms / 2,000 ms
コード長 948 bytes
コンパイル時間 1,003 ms
コンパイル使用メモリ 82,016 KB
実行使用メモリ 23,712 KB
最終ジャッジ日時 2024-07-16 01:37:02
合計ジャッジ時間 5,824 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
9,644 KB
testcase_01 AC 4 ms
9,524 KB
testcase_02 AC 4 ms
9,456 KB
testcase_03 AC 5 ms
9,668 KB
testcase_04 AC 79 ms
16,516 KB
testcase_05 AC 108 ms
15,428 KB
testcase_06 AC 65 ms
12,816 KB
testcase_07 AC 52 ms
12,572 KB
testcase_08 AC 84 ms
15,180 KB
testcase_09 AC 66 ms
12,844 KB
testcase_10 AC 54 ms
12,440 KB
testcase_11 AC 282 ms
19,788 KB
testcase_12 AC 160 ms
16,244 KB
testcase_13 AC 222 ms
18,616 KB
testcase_14 AC 32 ms
10,940 KB
testcase_15 AC 5 ms
9,596 KB
testcase_16 AC 5 ms
9,592 KB
testcase_17 AC 6 ms
9,644 KB
testcase_18 AC 95 ms
13,992 KB
testcase_19 AC 64 ms
12,816 KB
testcase_20 AC 153 ms
16,552 KB
testcase_21 AC 241 ms
19,128 KB
testcase_22 AC 88 ms
13,752 KB
testcase_23 AC 131 ms
16,036 KB
testcase_24 AC 133 ms
15,936 KB
testcase_25 AC 45 ms
13,248 KB
testcase_26 AC 163 ms
23,712 KB
testcase_27 AC 85 ms
16,548 KB
testcase_28 AC 10 ms
10,924 KB
testcase_29 AC 15 ms
11,488 KB
testcase_30 AC 44 ms
14,200 KB
testcase_31 AC 64 ms
13,068 KB
testcase_32 AC 114 ms
19,148 KB
testcase_33 AC 164 ms
18,500 KB
testcase_34 AC 5 ms
9,600 KB
testcase_35 AC 6 ms
9,544 KB
testcase_36 AC 71 ms
12,640 KB
testcase_37 AC 77 ms
13,316 KB
testcase_38 AC 162 ms
16,332 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<queue>
#include<vector>
#include<cassert>
using namespace std;
int N,M,L,S,E;
vector<pair<int,int> >G[2<<17];
vector<long>f(int s)
{
	vector<long>ret(N,(long)1e18);
	ret[s]=0;
	priority_queue<pair<long,int> >Q;
	Q.push(make_pair(0,s));
	while(!Q.empty())
	{
		int u=Q.top().second;
		long d=-Q.top().first;
		Q.pop();
		if(ret[u]<d)continue;
		for(auto e:G[u])
		{
			int v=e.first;
			long nd=d+e.second;
			if(ret[v]>nd)
			{
				ret[v]=nd;
				Q.push(make_pair(-nd,v));
			}
		}
	}
	return ret;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin>>N>>M>>L>>S>>E;
	for(int i=0;i<M;i++)
	{
		int a,b,c;cin>>a>>b>>c;
		a--,b--;
		G[a].push_back(make_pair(b,c));
		G[b].push_back(make_pair(a,c));
	}
	vector<long>s=f(0),T=f(N-1);
	long ans=1e18;
	for(int i=0;i<L;i++)
	{
		int t;cin>>t;t--;
		long v=max(s[t],(long)S);
		if(v<S+E)ans=min(ans,v+1+T[t]);
	}
	if(ans>=(long)1e18)ans=-1;
	cout<<ans<<endl;
}
0