結果

問題 No.2387 Yokan Factory
ユーザー t98slidert98slider
提出日時 2023-07-21 21:35:38
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 1,332 bytes
コンパイル時間 2,082 ms
コンパイル使用メモリ 187,856 KB
実行使用メモリ 20,664 KB
最終ジャッジ日時 2024-09-21 22:55:04
合計ジャッジ時間 9,537 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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<tuple<ll,ll,ll,ll>> edge(m);
    for(int i = 0; i < m; i++){
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        a--, b--;
        edge[i] = make_tuple(a, b, c, d);
    }
    while(ok + 1 < ng){
        mid = (ok + ng) / 2;
        vector<vector<pair<int, ll>>> g(n);
        for(int i = 0; i < m; i++){
            ll a, b, c, d;
            tie(a, b, c, d) = edge[i];
            if(d < mid) continue;
            g[a].emplace_back(b, c);
            g[b].emplace_back(a, c);
        }
        priority_queue<pair<ll,int>, vector<pair<ll,int>>, greater<pair<ll,int>>> pq;
        vector<ll> dist(n, 1ll << 60);
        pq.emplace(0, 0);
        dist[0] = 0;
        while(!pq.empty()){
            ll d, c;
            int v, u;
            tie(d, v) = pq.top();
            pq.pop();
            if(dist[v] > d) continue;
            for(auto &&pa : g[v]){
                tie(u, c) = pa;
                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