結果

問題 No.2387 Yokan Factory
ユーザー t98slidert98slider
提出日時 2023-07-21 21:38:12
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 1,194 bytes
コンパイル時間 1,994 ms
コンパイル使用メモリ 184,108 KB
実行使用メモリ 17,368 KB
最終ジャッジ日時 2024-09-21 23:01:06
合計ジャッジ時間 9,212 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14 TLE * 1 -- * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, m, x, ok = -1, ng = 1ll << 30, mid;
    cin >> n >> m >> x;
    vector<vector<tuple<int, ll, ll>>> g(n);
    vector<ll> dist(n, 1ll << 60);
    for(int i = 0; i < m; i++){
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        a--, b--;
        g[a].emplace_back(b, c, d);
        g[b].emplace_back(a, c, d);
    }
    while(ok + 1 < ng){
        mid = (ok + ng) / 2;
        priority_queue<pair<ll,int>, vector<pair<ll,int>>, greater<pair<ll,int>>> pq;
        fill(dist.begin(), dist.end(), 1ll << 60);
        pq.emplace(0, 0);
        dist[0] = 0;
        while(!pq.empty()){
            ll d, c, e;
            int v, u;
            tie(d, v) = pq.top();
            pq.pop();
            if(dist[v] > d) continue;
            for(auto &&pa : g[v]){
                tie(u, c, e) = pa;
                if(e < mid) continue;
                if(d + c >= dist[u]) continue;
                dist[u] = d + c;
                pq.emplace(d + c, u);
            }
        }
        (dist[n - 1] <= x ? ok : ng) = mid;
    }
    cout << ok << '\n';
}
0