結果

問題 No.2387 Yokan Factory
ユーザー eve__fuyukieve__fuyuki
提出日時 2023-07-31 10:19:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 344 ms / 5,000 ms
コード長 1,381 bytes
コンパイル時間 2,451 ms
コンパイル使用メモリ 209,044 KB
実行使用メモリ 10,488 KB
最終ジャッジ日時 2024-04-18 10:46:57
合計ジャッジ時間 7,104 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 176 ms
10,488 KB
testcase_16 AC 87 ms
10,236 KB
testcase_17 AC 251 ms
10,444 KB
testcase_18 AC 185 ms
9,760 KB
testcase_19 AC 202 ms
7,848 KB
testcase_20 AC 200 ms
7,312 KB
testcase_21 AC 344 ms
9,460 KB
testcase_22 AC 171 ms
6,940 KB
testcase_23 AC 223 ms
7,648 KB
testcase_24 AC 96 ms
7,136 KB
testcase_25 AC 141 ms
5,896 KB
testcase_26 AC 249 ms
8,284 KB
testcase_27 AC 326 ms
9,004 KB
testcase_28 AC 3 ms
5,376 KB
testcase_29 AC 4 ms
5,376 KB
testcase_30 AC 3 ms
5,376 KB
testcase_31 AC 3 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 4 ms
5,376 KB
testcase_35 AC 2 ms
5,376 KB
testcase_36 AC 2 ms
5,376 KB
testcase_37 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
void fast_io() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
}

int main() {
    fast_io();
    int n, m;
    long long x;
    cin >> n >> m >> x;
    vector<vector<tuple<int, int, long long>>> g(n);
    for (int i = 0; i < m; i++) {
        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});
    }
    long long ok = -1, ng = 1e10;
    using pli = pair<long long, int>;
    while (ok + 1 < ng) {
        long long mid = ok + (ng - ok) / 2;
        vector<long long> dist(n, 9e18);
        vector<bool> vis(n, false);
        priority_queue<pli, vector<pli>, greater<pli>> que;
        dist[0] = 0;
        que.push({0, 0});
        while (!que.empty()) {
            auto [d, u] = que.top();
            que.pop();
            if (vis[u]) {
                continue;
            }
            vis[u] = true;
            for (auto [v, a, b] : g[u]) {
                if (mid > b) {
                    continue;
                }
                if (dist[v] > d + a) {
                    dist[v] = d + a;
                    que.push({d + a, v});
                }
            }
        }
        if (dist[n - 1] <= x) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    cout << ok << endl;
}
0