結果

問題 No.2387 Yokan Factory
ユーザー tabrtabr
提出日時 2023-07-21 21:32:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 374 ms / 5,000 ms
コード長 1,465 bytes
コンパイル時間 2,300 ms
コンパイル使用メモリ 213,480 KB
実行使用メモリ 10,112 KB
最終ジャッジ日時 2023-10-21 21:24:03
合計ジャッジ時間 6,096 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 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 148 ms
8,868 KB
testcase_16 AC 97 ms
9,888 KB
testcase_17 AC 271 ms
10,112 KB
testcase_18 AC 374 ms
9,204 KB
testcase_19 AC 147 ms
6,876 KB
testcase_20 AC 74 ms
6,596 KB
testcase_21 AC 307 ms
8,672 KB
testcase_22 AC 82 ms
6,340 KB
testcase_23 AC 269 ms
6,996 KB
testcase_24 AC 80 ms
6,488 KB
testcase_25 AC 93 ms
5,660 KB
testcase_26 AC 145 ms
7,260 KB
testcase_27 AC 84 ms
8,032 KB
testcase_28 AC 3 ms
4,348 KB
testcase_29 AC 2 ms
4,348 KB
testcase_30 AC 3 ms
4,348 KB
testcase_31 AC 3 ms
4,348 KB
testcase_32 AC 2 ms
4,348 KB
testcase_33 AC 2 ms
4,348 KB
testcase_34 AC 3 ms
4,348 KB
testcase_35 AC 3 ms
4,348 KB
testcase_36 AC 2 ms
4,348 KB
testcase_37 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m;
    long long f;
    cin >> n >> m >> f;
    vector<int> x(m), y(m), a(m), b(m);
    vector<vector<int>> g(n);
    for (int i = 0; i < m; i++) {
        cin >> x[i] >> y[i] >> a[i] >> b[i];
        x[i]--;
        y[i]--;
        g[x[i]].emplace_back(i);
        g[y[i]].emplace_back(i);
    }
    int low = -1, high = 1e9 + 10;
    while (high - low > 1) {
        auto mid = (high + low) >> 1;
        vector<long long> d(n, f + 1);
        priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> pq;
        d[0] = 0;
        pq.emplace(d[0], 0);
        while (!pq.empty()) {
            auto [dv, v] = pq.top();
            pq.pop();
            if (d[v] != dv) {
                continue;
            }
            for (int id : g[v]) {
                int to = x[id] ^ y[id] ^ v;
                if (b[id] < mid) {
                    continue;
                }
                long long cost = d[v] + a[id];
                if (d[to] > cost) {
                    d[to] = cost;
                    pq.emplace(d[to], to);
                }
            }
        }
        if (d[n - 1] <= f) {
            low = mid;
        } else {
            high = mid;
        }
    }
    cout << low << '\n';
    return 0;
}
0