結果

問題 No.2387 Yokan Factory
ユーザー cleanttedcleantted
提出日時 2023-06-14 14:46:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,375 bytes
コンパイル時間 1,008 ms
コンパイル使用メモリ 96,876 KB
実行使用メモリ 13,056 KB
最終ジャッジ日時 2023-09-06 01:06:58
合計ジャッジ時間 4,755 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

bool f(const vector<vector<tuple<ll, ll, ll>>>& G, ll N, ll X, ll m) {
    priority_queue<tuple<ll, ll>> S;
    vector<bool> fixed(N, false);
    vector<ll> D(N, X + 1);
    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 (c + a > X) {
          continue;
        }
        D[j] = c + a;
        S.push(make_tuple(c + a, j));
      }
    }
    return D[N - 1] <= X;
}

int main() {
    ll N, M, X;
    cin >> N >> M >> X;
    
    ll u, v, a, b;
    vector<vector<tuple<ll, ll, ll>>> 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));
    }
    
    ll l = -1;
    ll r = 1e9 + 10;
    while (r - l > 1) {
        ll m = (l + r) / 2;
        if (f(G, N, X, m)) {
            l = m;
        } else {
            r = m;
        }
    }

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