結果

問題 No.1473 おでぶなおばけさん
ユーザー Manuel1024Manuel1024
提出日時 2021-04-27 22:44:03
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 204 ms / 2,000 ms
コード長 1,172 bytes
コンパイル時間 692 ms
コンパイル使用メモリ 80,820 KB
実行使用メモリ 9,736 KB
最終ジャッジ日時 2023-09-20 22:56:53
合計ジャッジ時間 7,800 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 168 ms
9,168 KB
testcase_03 AC 123 ms
8,628 KB
testcase_04 AC 103 ms
6,712 KB
testcase_05 AC 40 ms
4,408 KB
testcase_06 AC 170 ms
8,912 KB
testcase_07 AC 156 ms
9,656 KB
testcase_08 AC 204 ms
9,736 KB
testcase_09 AC 156 ms
9,668 KB
testcase_10 AC 84 ms
5,184 KB
testcase_11 AC 86 ms
6,188 KB
testcase_12 AC 84 ms
5,716 KB
testcase_13 AC 51 ms
4,708 KB
testcase_14 AC 37 ms
4,380 KB
testcase_15 AC 71 ms
5,332 KB
testcase_16 AC 81 ms
5,228 KB
testcase_17 AC 7 ms
4,376 KB
testcase_18 AC 11 ms
4,380 KB
testcase_19 AC 74 ms
5,936 KB
testcase_20 AC 95 ms
7,836 KB
testcase_21 AC 118 ms
6,664 KB
testcase_22 AC 92 ms
8,340 KB
testcase_23 AC 74 ms
8,056 KB
testcase_24 AC 76 ms
7,720 KB
testcase_25 AC 179 ms
8,404 KB
testcase_26 AC 182 ms
8,000 KB
testcase_27 AC 57 ms
4,768 KB
testcase_28 AC 172 ms
9,616 KB
testcase_29 AC 127 ms
6,988 KB
testcase_30 AC 152 ms
7,484 KB
testcase_31 AC 128 ms
9,232 KB
testcase_32 AC 128 ms
9,292 KB
testcase_33 AC 100 ms
7,800 KB
testcase_34 AC 55 ms
5,408 KB
testcase_35 AC 59 ms
5,616 KB
testcase_36 AC 101 ms
6,296 KB
testcase_37 AC 116 ms
7,528 KB
testcase_38 AC 23 ms
4,376 KB
testcase_39 AC 83 ms
4,980 KB
testcase_40 AC 83 ms
4,864 KB
testcase_41 AC 73 ms
4,784 KB
testcase_42 AC 73 ms
4,936 KB
testcase_43 AC 92 ms
7,224 KB
testcase_44 AC 91 ms
6,864 KB
testcase_45 AC 90 ms
7,032 KB
testcase_46 AC 105 ms
7,264 KB
testcase_47 AC 130 ms
8,476 KB
testcase_48 AC 121 ms
7,936 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <queue>
using namespace std;
using P = pair<int, int>;
constexpr int INF = 1001001001;

int isReachable(const vector<vector<P>> &G, int obakeW){
    vector<int> dist(G.size(), INF);
    queue<int> Q;
    Q.push(0);
    dist[0] = 0;
    while(Q.size()){
        int cur = Q.front(); Q.pop();
        for(auto &p: G[cur]){
            if(p.second >= obakeW && dist[p.first] == INF){
                dist[p.first] = dist[cur]+1;
                Q.push(p.first);
            }
        }
    }
    //cerr << limWeight << " " << dist[0] << " " << dist[1] << " " << dist[2] << endl;
    return dist[G.size()-1];
}

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

    vector<vector<P>> G(n);
    for(int i = 0; i < m; i++){
        int s, t, d;
        cin >> s >> t >> d;
        s--; t--;
        G[s].push_back(make_pair(t, d));
        G[t].push_back(make_pair(s, d));
    }

    int ac = 0;
    int wa = INF;
    while(wa-ac > 1){
        int mid = (wa+ac)/2;
        int res = isReachable(G, mid);
        if(res == INF) wa = mid;
        else ac = mid;
    }

    cout << ac << " " << isReachable(G, ac) << endl;
    return 0;
}
0