結果

問題 No.1473 おでぶなおばけさん
ユーザー sten_sansten_san
提出日時 2021-04-09 21:51:29
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,810 bytes
コンパイル時間 2,128 ms
コンパイル使用メモリ 210,372 KB
実行使用メモリ 9,592 KB
最終ジャッジ日時 2023-09-07 10:55:38
合計ジャッジ時間 6,058 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 90 ms
9,592 KB
testcase_08 AC 132 ms
9,412 KB
testcase_09 AC 82 ms
9,356 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
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 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

struct iofast_t {
    iofast_t() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr); cout.tie(nullptr);
    }
} iofast;

struct uns_t {} uns;
template <typename Element, typename Head, typename ...Args>
auto vec(Element init, Head arg, Args ...args) {
    if constexpr (sizeof...(Args) == 0) return std::vector(arg, init);
    else return std::vector(arg, vec(init, args...));
}
template <typename Element, typename Head, typename ...Args>
auto vec(uns_t, Head arg, Args ...args) {
    return vec(Element(), arg, args...);
}

template <typename T, typename Compare = less<T>>
T &chmin(T &l, T r, Compare &&f = less<T>()) { return l = min(l, r, f); }
template <typename T, typename Compare = less<T>>
T &chmax(T &l, T r, Compare &&f = less<T>()) { return l = max(l, r, f); }

int main() {
    int n, m; cin >> n >> m;

    auto g = vec<tuple<int, int>>(uns, n, 0);
    for (int i = 0; i < n; ++i) {
        int s, t, d; cin >> s >> t >> d; --s; --t;
        g[s].emplace_back(t, d);
        g[t].emplace_back(s, d);
    }

    auto check = [&](int w) {
        auto dist = vec<int>(-1, n);
        queue<int> que;

        dist[0] = 0;
        que.push(0);
        while (!empty(que)) {
            auto c = que.front(); que.pop();
            for (auto [v, d] : g[c]) {
                if (d < w || dist[v] != -1) continue;
                dist[v] = dist[c] + 1;
                que.push(v);
            }
        }

        return dist[n - 1];
    };

    int64_t left = 0, right = 1000000000 + 1;
    while (1 < right - left) {
        auto mid = left + (right - left) / 2;

        if (0 <= check(mid)) {
            left = mid;
        }
        else {
            right = mid;
        }
    }

    cout << left << ' ' << check(left) << endl;
}

0