結果

問題 No.2387 Yokan Factory
ユーザー PAKACHUPAKACHU
提出日時 2023-07-21 22:06:34
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 637 ms / 5,000 ms
コード長 1,453 bytes
コンパイル時間 2,291 ms
コンパイル使用メモリ 163,336 KB
実行使用メモリ 9,904 KB
最終ジャッジ日時 2023-10-21 22:07:31
合計ジャッジ時間 8,936 ms
ジャッジサーバーID
(参考情報)
judge10 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 250 ms
9,904 KB
testcase_16 AC 171 ms
9,092 KB
testcase_17 AC 366 ms
9,340 KB
testcase_18 AC 448 ms
9,284 KB
testcase_19 AC 452 ms
7,364 KB
testcase_20 AC 304 ms
6,748 KB
testcase_21 AC 637 ms
8,780 KB
testcase_22 AC 254 ms
6,476 KB
testcase_23 AC 456 ms
7,408 KB
testcase_24 AC 199 ms
6,976 KB
testcase_25 AC 244 ms
5,832 KB
testcase_26 AC 591 ms
8,092 KB
testcase_27 AC 598 ms
8,600 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 2 ms
4,348 KB
testcase_34 AC 5 ms
4,348 KB
testcase_35 AC 4 ms
4,348 KB
testcase_36 AC 2 ms
4,348 KB
testcase_37 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
int dx[8] = { 1, 0, -1, 0, 1, 1, -1, -1 }, dy[8] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const long long mod = 998244353;
const ll inf = 1LL << 60;
const int INF = 1e9 + 1;

int main()
{
    int n, m;
    ll x;
    cin >> n >> m >> x;
    vector<vector<tuple<int, int, int>>> g(n);
    for (int i = 0; i < m; i++) {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        u--;
        v--;
        g[u].emplace_back(v, a, b);
        g[v].emplace_back(u, a, b);
    }

    auto check = [&](int k) {
        priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> q;
        vector<ll> d(n, inf);
        q.emplace(0, 0);
        while (q.size()) {
            auto [dist, u] = q.top();
            q.pop();
            if (dist >= d[u])
                continue;
            d[u] = dist;
            for (auto [v, a, b] : g[u]) {
                if (b < k)
                    continue;
                if (dist + a >= d[v])
                    continue;
                q.emplace(dist + a, v);
            }
        }
        return d[n - 1] <= x;
    };

    int l = 0, r = INF;
    while (r - l > 1) {
        int mid = (r + l) / 2;
        if (check(mid))
            l = mid;
        else
            r = mid;
    }
    if (l == 0)
        cout << -1 << endl;
    else
        cout << l << endl;
}
0