結果

問題 No.2387 Yokan Factory
ユーザー k82bk82b
提出日時 2023-07-21 21:54:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 937 bytes
コンパイル時間 867 ms
コンパイル使用メモリ 84,528 KB
実行使用メモリ 11,612 KB
最終ジャッジ日時 2023-10-21 21:55:14
合計ジャッジ時間 8,431 ms
ジャッジサーバーID
(参考情報)
judge15 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
7,060 KB
testcase_01 AC 2 ms
7,060 KB
testcase_02 AC 3 ms
7,060 KB
testcase_03 AC 3 ms
7,064 KB
testcase_04 AC 3 ms
7,064 KB
testcase_05 AC 3 ms
7,064 KB
testcase_06 AC 2 ms
7,064 KB
testcase_07 AC 3 ms
7,064 KB
testcase_08 AC 3 ms
7,064 KB
testcase_09 AC 3 ms
7,064 KB
testcase_10 AC 3 ms
7,060 KB
testcase_11 AC 3 ms
7,060 KB
testcase_12 AC 3 ms
7,060 KB
testcase_13 AC 3 ms
7,060 KB
testcase_14 AC 3 ms
7,060 KB
testcase_15 AC 221 ms
11,612 KB
testcase_16 AC 159 ms
11,240 KB
testcase_17 TLE -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<queue>
long N,M,X;
std::vector<std::pair<int,std::pair<int,int>>>G[1<<17];
long dist[1<<17];
std::priority_queue<std::pair<long,int>>Q;
int main()
{
	std::cin>>N>>M>>X;
	for(int i=0;i<M;++i)
	{
		int u,v,a,b;
		std::cin>>u>>v>>a>>b;
		u--,v--;
		G[u].push_back(std::make_pair(v,std::make_pair(a,b)));
		G[v].push_back(std::make_pair(u,std::make_pair(a,b)));
	}
	int L=0,R=1e9+1;
	while(R-L>1)
	{
		int mid=(L+R)/2;
		for(int i=1;i<N;++i)dist[i]=1e18;
		Q.push({0,0});
		while(!Q.empty())
		{
			auto[c,u]=Q.top();Q.pop();
			c=-c;
			if(dist[u]>c)continue;
			for(std::pair<int,std::pair<int,int>>p:G[u])
			{
				int v=p.first;
				auto[a,b]=p.second;
				if(b<mid)continue;
				if(dist[u]+a>X)continue;
				if(dist[v]>dist[u]+a)
				{
					dist[v]=dist[u]+a;
					Q.push({-dist[v],v});
				}
			}
		}
		if(dist[N-1]!=(long)1e18)L=mid;
		else R=mid;
	}
	if(L==0)L=-1;
	std::cout<<L<<"\n";
}
0