結果

問題 No.1473 おでぶなおばけさん
ユーザー hourenhouren
提出日時 2021-12-01 22:43:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 216 ms / 2,000 ms
コード長 1,099 bytes
コンパイル時間 2,194 ms
コンパイル使用メモリ 176,544 KB
実行使用メモリ 9,304 KB
最終ジャッジ日時 2023-09-18 08:31:53
合計ジャッジ時間 8,985 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 162 ms
9,100 KB
testcase_03 AC 134 ms
8,336 KB
testcase_04 AC 105 ms
6,584 KB
testcase_05 AC 41 ms
4,380 KB
testcase_06 AC 181 ms
8,656 KB
testcase_07 AC 170 ms
9,264 KB
testcase_08 AC 216 ms
9,268 KB
testcase_09 AC 158 ms
9,284 KB
testcase_10 AC 86 ms
5,112 KB
testcase_11 AC 89 ms
6,216 KB
testcase_12 AC 87 ms
5,660 KB
testcase_13 AC 53 ms
4,576 KB
testcase_14 AC 38 ms
4,376 KB
testcase_15 AC 74 ms
5,328 KB
testcase_16 AC 83 ms
5,144 KB
testcase_17 AC 8 ms
4,376 KB
testcase_18 AC 12 ms
4,380 KB
testcase_19 AC 77 ms
5,544 KB
testcase_20 AC 100 ms
7,828 KB
testcase_21 AC 121 ms
6,660 KB
testcase_22 AC 95 ms
8,352 KB
testcase_23 AC 77 ms
7,992 KB
testcase_24 AC 77 ms
7,720 KB
testcase_25 AC 206 ms
8,376 KB
testcase_26 AC 213 ms
8,432 KB
testcase_27 AC 62 ms
4,668 KB
testcase_28 AC 173 ms
9,304 KB
testcase_29 AC 124 ms
6,976 KB
testcase_30 AC 157 ms
7,480 KB
testcase_31 AC 135 ms
9,180 KB
testcase_32 AC 136 ms
8,876 KB
testcase_33 AC 105 ms
7,716 KB
testcase_34 AC 58 ms
5,380 KB
testcase_35 AC 59 ms
5,424 KB
testcase_36 AC 105 ms
6,088 KB
testcase_37 AC 136 ms
7,540 KB
testcase_38 AC 22 ms
4,376 KB
testcase_39 AC 84 ms
4,796 KB
testcase_40 AC 84 ms
4,844 KB
testcase_41 AC 77 ms
4,852 KB
testcase_42 AC 75 ms
4,780 KB
testcase_43 AC 92 ms
6,884 KB
testcase_44 AC 92 ms
6,948 KB
testcase_45 AC 92 ms
6,912 KB
testcase_46 AC 110 ms
7,276 KB
testcase_47 AC 140 ms
8,164 KB
testcase_48 AC 129 ms
7,708 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:43:26: 警告: ‘ans’ may be used uninitialized [-Wmaybe-uninitialized]
   43 |     cout << ok << " " << ans << endl;
      |                          ^~~
main.cpp:19:34: 備考: ‘ans’ はここで定義されています
   19 |     int ok = 0, ng = 1000000001, ans;
      |                                  ^~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()

int main(){
    int n,m;
    cin >> n >> m;
    vector<vector<P>> to(n);
    rep(i,m){
        int s,t,d;
        cin >> s >> t >> d;
        s--; t--;
        to[s].push_back(make_pair(t,d));
        to[t].push_back(make_pair(s,d));
    }
    int ok = 0, ng = 1000000001, ans;
    while(ng-ok != 1){
        int md = (ng + ok) / 2;
        vector<int> dist(n,-1);
        dist[0] = 0;
        queue<int> que;
        que.push(0);
        while(que.size()){
            int now = que.front();
            que.pop();
            for(auto p:to[now]){
                int x,w;
                tie(x,w) = p;
                if(w < md || dist[x] != -1) continue;
                dist[x] = dist[now] + 1;
                que.push(x);
            }
        }
        if(dist[n-1] != -1){
            ok = md;
            ans = dist[n-1];
        }
        else ng = md;
    }
    cout << ok << " " << ans << endl;
    return 0;
}
0