結果

問題 No.2387 Yokan Factory
ユーザー cubinglovercubinglover
提出日時 2023-07-21 21:58:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 369 ms / 5,000 ms
コード長 859 bytes
コンパイル時間 905 ms
コンパイル使用メモリ 85,740 KB
実行使用メモリ 10,256 KB
最終ジャッジ日時 2023-10-21 22:00:24
合計ジャッジ時間 5,494 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 216 ms
10,256 KB
testcase_16 AC 151 ms
9,292 KB
testcase_17 AC 284 ms
9,284 KB
testcase_18 AC 295 ms
9,096 KB
testcase_19 AC 244 ms
7,172 KB
testcase_20 AC 202 ms
6,948 KB
testcase_21 AC 369 ms
8,716 KB
testcase_22 AC 185 ms
6,676 KB
testcase_23 AC 257 ms
7,220 KB
testcase_24 AC 124 ms
6,784 KB
testcase_25 AC 155 ms
5,768 KB
testcase_26 AC 291 ms
7,636 KB
testcase_27 AC 355 ms
8,536 KB
testcase_28 AC 4 ms
4,348 KB
testcase_29 AC 4 ms
4,348 KB
testcase_30 AC 4 ms
4,348 KB
testcase_31 AC 3 ms
4,348 KB
testcase_32 AC 2 ms
4,348 KB
testcase_33 AC 2 ms
4,348 KB
testcase_34 AC 4 ms
4,348 KB
testcase_35 AC 4 ms
4,348 KB
testcase_36 AC 2 ms
4,348 KB
testcase_37 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<queue>
#include<vector>
using namespace std;
struct edge{
	int to, a, b;
};
int main(){
	int n,m;
	long long x;
	cin>>n>>m>>x;

	vector<vector<edge>> G(n);
	
	for(int i=0;i<m;++i){
		int u,v,a,b;cin>>u>>v>>a>>b;
		--u,--v;
		G[u].push_back({v,a,b});
		G[v].push_back({u,a,b});
	}
	
	long long l=-1,r=1e9+5;
	
	priority_queue<pair<long long,int>, vector<pair<long long,int>>, greater<pair<long long, int>>> que;
	while(r-l>1){
		long long m=(l+r)/2;

		vector<long long> dist(n, 1e18+5);
		dist[0]=0;
		que.push({0,0});

		while(!que.empty()){
			auto [d,v]=que.top();
			que.pop();
			if(dist[v]!=d)continue;
			for(const auto&[to, a, b]:G[v]){
				if(b<m)continue;
				if(dist[to]>d+a){
					dist[to]=d+a;
					que.push({d+a,to});
				}
			}
		}
		
		if(dist[n-1]<=x){
			l=m;
		}else{
			r=m;
		}
	}
	cout<<l<<endl;
	return 0;
}
0