結果

問題 No.2387 Yokan Factory
ユーザー hourenhouren
提出日時 2023-07-21 22:00:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 475 ms / 5,000 ms
コード長 1,437 bytes
コンパイル時間 1,777 ms
コンパイル使用メモリ 180,212 KB
実行使用メモリ 9,920 KB
最終ジャッジ日時 2023-10-21 22:02:12
合計ジャッジ時間 6,899 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 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 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 188 ms
9,920 KB
testcase_16 AC 111 ms
9,108 KB
testcase_17 AC 289 ms
9,356 KB
testcase_18 AC 328 ms
8,956 KB
testcase_19 AC 246 ms
7,112 KB
testcase_20 AC 194 ms
6,764 KB
testcase_21 AC 475 ms
8,544 KB
testcase_22 AC 189 ms
6,496 KB
testcase_23 AC 269 ms
7,160 KB
testcase_24 AC 100 ms
6,692 KB
testcase_25 AC 152 ms
5,588 KB
testcase_26 AC 311 ms
7,624 KB
testcase_27 AC 415 ms
8,344 KB
testcase_28 AC 3 ms
4,348 KB
testcase_29 AC 3 ms
4,348 KB
testcase_30 AC 4 ms
4,348 KB
testcase_31 AC 4 ms
4,348 KB
testcase_32 AC 2 ms
4,348 KB
testcase_33 AC 3 ms
4,348 KB
testcase_34 AC 4 ms
4,348 KB
testcase_35 AC 3 ms
4,348 KB
testcase_36 AC 3 ms
4,348 KB
testcase_37 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define fix(x) fixed << setprecision(x)
#define asc(x) x, vector<x>, greater<x>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
template<class T>bool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool chmax(T&a, const T&b){if(a<b){a=b;return 1;}return 0;}
constexpr ll INFLL = (1LL << 62), MOD = 998244353;
constexpr int INF = (1 << 30);

struct Edge{ int to,a,b; };

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,m,x;
    cin >> n >> m >> x;
    vector<vector<Edge>> g(n);
    rep(i,m){
        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});
    }
    int ok = -1, ng = 1e9+1;
    while(ng-ok>1){
        int md = (ok+ng)/2;
        vector<ll> dist(n,INFLL);
        dist[0] = 0;
        priority_queue<asc(P)> pq;
        pq.push({0,0});
        while(pq.size()){
            ll d,now;
            tie(d,now) = pq.top();
            pq.pop();
            if(dist[now]<d) continue;
            for(Edge e:g[now]){
                if(md<=e.b){
                    if(chmin(dist[e.to], dist[now]+e.a)) pq.push({dist[e.to], e.to});
                }
            }
        }
        if(dist[n-1]<=x) ok = md;
        else ng = md;
    }
    cout << ok << '\n';
    return 0;
}
0