結果
| 問題 |
No.2387 Yokan Factory
|
| コンテスト | |
| ユーザー |
nonon
|
| 提出日時 | 2023-07-21 22:22:13 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,859 bytes |
| コンパイル時間 | 2,051 ms |
| コンパイル使用メモリ | 210,776 KB |
| 最終ジャッジ日時 | 2025-02-15 17:04:34 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 TLE * 1 -- * 20 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using db = long double;
using ch = char;
using bl = bool;
using st = string;
using pll = pair<ll,ll>;
using psl = pair<st,ll>;
using vst = vector<st>;
using vch = vector<ch>;
using vvch = vector<vch>;
using vbl = vector<bl>;
using vvbl = vector<vbl>;
using vdb = vector<db>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
using vpsl = vector<psl>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vvvvi = vector<vvvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vvvvll = vector<vvvll>;
using vvvvvll = vector<vvvvll>;
#define all(A) A.begin(),A.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rrep(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);i++)
int main() {
ll N,M,X;
cin>>N>>M>>X;
vector<vector<pair<ll,pll>>> G(N);
rep(i,M){
ll 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)));
}
ll l=0,r=1e9+1;
vbl seen;
vll dist;
while(r-l>1){
ll m=(l+r)/2;
seen.assign(N,0);
dist.assign(N,2e18);
priority_queue<pll,vpll,greater<pll>> q;
q.push(make_pair(0,0));
dist[0]=0;
while(!q.empty()){
ll v=q.top().second;
q.pop();
for(auto p:G[v]){
ll u=p.first,a=p.second.first,b=p.second.second;
if(seen[u])continue;
if(dist[u]>dist[v]+a && m<=b){
dist[u]=dist[v]+a;
q.push(make_pair(dist[u],u));
}
}
seen[v]=1;
}
if(dist[N-1]<=X)l=m;
else r=m;
}
if(l==0)cout << -1 << endl;
else cout << l << endl;
return 0;
}
nonon