結果

問題 No.2387 Yokan Factory
ユーザー erbowlerbowl
提出日時 2023-07-21 21:34:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 543 ms / 5,000 ms
コード長 1,180 bytes
コンパイル時間 2,257 ms
コンパイル使用メモリ 215,712 KB
実行使用メモリ 13,120 KB
最終ジャッジ日時 2023-10-21 21:25:57
合計ジャッジ時間 7,829 ms
ジャッジサーバーID
(参考情報)
judge14 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 262 ms
13,120 KB
testcase_16 AC 206 ms
12,092 KB
testcase_17 AC 382 ms
12,116 KB
testcase_18 AC 290 ms
11,016 KB
testcase_19 AC 301 ms
9,036 KB
testcase_20 AC 254 ms
8,436 KB
testcase_21 AC 528 ms
10,696 KB
testcase_22 AC 221 ms
8,004 KB
testcase_23 AC 354 ms
8,972 KB
testcase_24 AC 181 ms
8,356 KB
testcase_25 AC 184 ms
6,584 KB
testcase_26 AC 397 ms
9,664 KB
testcase_27 AC 543 ms
10,376 KB
testcase_28 AC 4 ms
4,348 KB
testcase_29 AC 5 ms
4,348 KB
testcase_30 AC 4 ms
4,348 KB
testcase_31 AC 4 ms
4,348 KB
testcase_32 AC 3 ms
4,348 KB
testcase_33 AC 3 ms
4,348 KB
testcase_34 AC 5 ms
4,348 KB
testcase_35 AC 4 ms
4,348 KB
testcase_36 AC 3 ms
4,348 KB
testcase_37 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

typedef long long ll;
typedef long double ld;

#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
    ll n,m,x;
    std::cin >> n>>m>>x;
    vector<vector<tuple<ll,ll,ll>>> edges(n);
    for (int i = 0; i < m; i++) {
        ll u,v,a,b;
        std::cin >> u>>v>>a>>b;
        u--;v--;
        edges[u].push_back({v,a,b});
        edges[v].push_back({u,a,b});
    }
    ll l = 0;
    ll r = 1e15;
    using P = pair<ll,ll>;
    while(r-l>1){
        ll m = (r+l)/2;
        
        vector<ll> dis(n,1e18);
        dis[0] = 0;
        
        priority_queue<P,vector<P>,greater<P>> pq;
        pq.push({0,0});
        while(!pq.empty()){
            auto [d, p] = pq.top();pq.pop();
            if(dis[p]<d)continue;
            for (auto e : edges[p]) {
                auto [v,a,b] = e;
                if(dis[v]>d+a&&b>=m){
                    dis[v] = d+a;
                    pq.push({dis[v], v});
                }
            }
        }
        if(dis[n-1]<=x){
            l = m;
        }else{
            r = m;
        }
    }
    if(l==0){
        std::cout << -1 << std::endl;
    }else{
        std::cout << l << std::endl;
    }
}
0