結果

問題 No.2387 Yokan Factory
ユーザー cleanttedcleantted
提出日時 2023-06-14 14:28:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,522 bytes
コンパイル時間 1,018 ms
コンパイル使用メモリ 99,156 KB
実行使用メモリ 8,684 KB
最終ジャッジ日時 2023-09-06 01:06:48
合計ジャッジ時間 3,713 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 2 ms
4,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 1 ms
4,380 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
4,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 1 ms
4,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 51 ms
5,296 KB
testcase_26 AC 100 ms
6,948 KB
testcase_27 AC 112 ms
7,636 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 2 ms
4,376 KB
testcase_36 WA -
testcase_37 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:15:18: 警告: ‘i’ may be used uninitialized [-Wmaybe-uninitialized]
   15 |     for (ll i; i < M; ++i) {
      |                ~~^~~
main.cpp:15:13: 備考: ‘i’ はここで定義されています
   15 |     for (ll i; i < M; ++i) {
      |             ^

ソースコード

diff #

#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <tuple>
using namespace std;
using ll = long long;

int main() {
    ll N, M, X;
    cin >> N >> M >> X;
    
    ll u, v, a, b;
    vector<vector<tuple<int, int, int>>> G(N);
    for (ll i; i < M; ++i) {
      cin >> u >> v >> a >> b;
      --u;
      --v;
      G[u].push_back(make_tuple(b, v, a));
      G[v].push_back(make_tuple(b, u, a));
    }
    
    auto f = [&](ll m) {
        priority_queue<tuple<ll, ll>> S;
        vector<bool> fixed(N, false);
        vector<ll> D(N, 1e18);
        D[0] = 0;
        S.push(make_tuple(0, 0));
        while (!S.empty()) {
            auto [c, i] = S.top();
            S.pop();
            if (i == N - 1) {
                break;
            }
            if (fixed[i]) {
                continue;
            }
            fixed[i] = true;
            for (auto& [b, j, a] : G[i]) {
                if (m > b) {
                    continue;
                }
                if (D[j] <= c + a) {
                    continue;
                }
                if (D[j] > X) {
                    continue;
                }
                D[j] = c + a;
                S.push(make_tuple(c + a, j));
            }
        }
        return D[N - 1] <= X;
    };

    ll l = -1;
    ll r = 1e9 + 10;
    while (r - l > 1) {
        ll m = (l + r) / 2;
        if (f(m)) {
            l = m;
        } else {
            r = m;
        }
    }

    cout << l << endl;
    
    return 0;
}
0