結果

問題 No.1473 おでぶなおばけさん
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2023-06-19 15:19:51
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 283 ms / 2,000 ms
コード長 1,003 bytes
コンパイル時間 2,442 ms
コンパイル使用メモリ 208,100 KB
実行使用メモリ 12,196 KB
最終ジャッジ日時 2023-09-09 10:34:09
合計ジャッジ時間 13,041 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,356 KB
testcase_02 AC 181 ms
11,312 KB
testcase_03 AC 141 ms
10,140 KB
testcase_04 AC 111 ms
8,152 KB
testcase_05 AC 45 ms
4,852 KB
testcase_06 AC 200 ms
11,104 KB
testcase_07 AC 197 ms
12,196 KB
testcase_08 AC 283 ms
12,128 KB
testcase_09 AC 189 ms
12,136 KB
testcase_10 AC 92 ms
7,272 KB
testcase_11 AC 94 ms
8,780 KB
testcase_12 AC 92 ms
8,172 KB
testcase_13 AC 54 ms
6,132 KB
testcase_14 AC 40 ms
5,192 KB
testcase_15 AC 77 ms
7,484 KB
testcase_16 AC 86 ms
6,740 KB
testcase_17 AC 8 ms
4,356 KB
testcase_18 AC 12 ms
4,352 KB
testcase_19 AC 83 ms
7,500 KB
testcase_20 AC 114 ms
9,496 KB
testcase_21 AC 138 ms
9,288 KB
testcase_22 AC 99 ms
10,436 KB
testcase_23 AC 80 ms
9,368 KB
testcase_24 AC 81 ms
9,384 KB
testcase_25 AC 234 ms
10,236 KB
testcase_26 AC 244 ms
10,476 KB
testcase_27 AC 69 ms
5,908 KB
testcase_28 AC 202 ms
12,096 KB
testcase_29 AC 135 ms
9,092 KB
testcase_30 AC 170 ms
10,092 KB
testcase_31 AC 164 ms
11,412 KB
testcase_32 AC 145 ms
11,516 KB
testcase_33 AC 109 ms
9,352 KB
testcase_34 AC 60 ms
6,664 KB
testcase_35 AC 62 ms
6,800 KB
testcase_36 AC 112 ms
8,092 KB
testcase_37 AC 140 ms
8,972 KB
testcase_38 AC 24 ms
4,432 KB
testcase_39 AC 88 ms
6,692 KB
testcase_40 AC 86 ms
6,692 KB
testcase_41 AC 77 ms
6,468 KB
testcase_42 AC 78 ms
6,528 KB
testcase_43 AC 95 ms
8,956 KB
testcase_44 AC 95 ms
8,960 KB
testcase_45 AC 96 ms
9,056 KB
testcase_46 AC 123 ms
9,424 KB
testcase_47 AC 150 ms
10,652 KB
testcase_48 AC 140 ms
10,216 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

ll bfs(vector<vector<pair<ll, ll>>> &E, ll X){
 
    ll N = E.size();
    ll from, start=0;

    queue<ll> que;
    vector<ll> dist(N, 1e18);
 
    dist[start] = 0;
    que.push(start);
 
    while(!que.empty()){
        from = que.front();
        que.pop();
        for (auto [to, C] : E[from]){
            if (X > C) continue;
            if (dist[to] == 1e18){
                dist[to] = dist[from]+1;
                que.push(to);
            }
        }
    }

    return dist[N-1];
}

int main(){

    ll N, M, A, B, C, D;
    cin >> N >> M;
    vector<vector<pair<ll, ll>>> E(N);
    for (int i=0; i<M; i++){
        cin >> A >> B >> C;
        A--; B--;
        E[A].push_back({B, C});
        E[B].push_back({A, C});
    }

    ll l=0, r=1e9+1, c;

    while(r-l>1){
        c=(l+r)/2;
        D = bfs(E, c);
        if (D != 1e18) l=c;
        else r=c;
    }

    cout << l << " " << bfs(E, l) << endl;

    return 0;
}
0