結果
| 問題 |
No.2387 Yokan Factory
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-07-21 21:30:10 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 261 ms / 5,000 ms |
| コード長 | 922 bytes |
| コンパイル時間 | 739 ms |
| コンパイル使用メモリ | 80,096 KB |
| 実行使用メモリ | 11,244 KB |
| 最終ジャッジ日時 | 2024-09-21 22:47:42 |
| 合計ジャッジ時間 | 3,954 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 35 |
ソースコード
#include<iostream>
#include<queue>
#include<cassert>
using namespace std;
int N,M;
long X;
vector<pair<int,pair<int,int> > >G[1<<17];
long D[1<<17];
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin>>N>>M>>X;
for(int i=0;i<M;i++)
{
int u,v,a,b;
cin>>u>>v>>a>>b;
u--,v--;
G[u].push_back(make_pair(v,make_pair(a,b)));
G[v].push_back(make_pair(u,make_pair(a,b)));
}
int L=0,R=(int)1e9+1;
while(R-L>1)
{
int mid=(L+R)/2;
for(int i=1;i<N;i++)D[i]=X+1;
priority_queue<pair<long,int> >Q;
Q.push(make_pair(0,0));
while(!Q.empty())
{
int u=Q.top().second;
long d=-Q.top().first;
Q.pop();
if(D[u]<d)continue;
for(pair<int,pair<int,int> >e:G[u])if(e.second.second>=mid)
{
int v=e.first;
long nd=d+e.second.first;
if(D[v]>nd)
{
D[v]=nd;
Q.push(make_pair(-nd,v));
}
}
}
if(D[N-1]<=X)L=mid;
else R=mid;
}
cout<<(L==0?-1:L)<<endl;
}