結果

問題 No.1473 おでぶなおばけさん
ユーザー MZKiMZKi
提出日時 2021-04-09 22:08:41
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 235 ms / 2,000 ms
コード長 1,389 bytes
コンパイル時間 1,989 ms
コンパイル使用メモリ 152,644 KB
実行使用メモリ 10,560 KB
最終ジャッジ日時 2023-09-07 11:31:17
合計ジャッジ時間 9,927 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,256 KB
testcase_01 AC 4 ms
5,308 KB
testcase_02 AC 178 ms
9,752 KB
testcase_03 AC 135 ms
9,188 KB
testcase_04 AC 109 ms
8,292 KB
testcase_05 AC 43 ms
6,596 KB
testcase_06 AC 190 ms
9,592 KB
testcase_07 AC 186 ms
10,444 KB
testcase_08 AC 235 ms
10,560 KB
testcase_09 AC 168 ms
10,464 KB
testcase_10 AC 87 ms
7,600 KB
testcase_11 AC 89 ms
8,332 KB
testcase_12 AC 88 ms
8,068 KB
testcase_13 AC 54 ms
7,280 KB
testcase_14 AC 41 ms
6,492 KB
testcase_15 AC 75 ms
7,920 KB
testcase_16 AC 83 ms
7,160 KB
testcase_17 AC 9 ms
5,200 KB
testcase_18 AC 13 ms
5,692 KB
testcase_19 AC 81 ms
7,520 KB
testcase_20 AC 106 ms
8,832 KB
testcase_21 AC 124 ms
8,596 KB
testcase_22 AC 105 ms
9,428 KB
testcase_23 AC 84 ms
8,700 KB
testcase_24 AC 86 ms
8,904 KB
testcase_25 AC 221 ms
9,376 KB
testcase_26 AC 221 ms
9,528 KB
testcase_27 AC 66 ms
7,060 KB
testcase_28 AC 194 ms
10,360 KB
testcase_29 AC 134 ms
8,836 KB
testcase_30 AC 173 ms
9,196 KB
testcase_31 AC 153 ms
9,996 KB
testcase_32 AC 148 ms
10,024 KB
testcase_33 AC 113 ms
8,800 KB
testcase_34 AC 61 ms
7,384 KB
testcase_35 AC 63 ms
7,496 KB
testcase_36 AC 111 ms
8,040 KB
testcase_37 AC 135 ms
8,684 KB
testcase_38 AC 25 ms
6,236 KB
testcase_39 AC 87 ms
7,216 KB
testcase_40 AC 85 ms
7,268 KB
testcase_41 AC 76 ms
7,172 KB
testcase_42 AC 76 ms
7,276 KB
testcase_43 AC 93 ms
8,584 KB
testcase_44 AC 92 ms
8,708 KB
testcase_45 AC 94 ms
8,652 KB
testcase_46 AC 126 ms
9,148 KB
testcase_47 AC 156 ms
9,600 KB
testcase_48 AC 140 ms
9,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define eps (double)(1e-9)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

struct edge{
    int to, li;
};

vector<vector<edge>> G(100010);

ll BFS(ll w, int n){
    vector<ll> d(n, inf);
    d[0] = 0;
    queue<ll> que;
    que.push(0);
    while(!que.empty()){
        ll v = que.front();
        que.pop();
        for(auto nv : G[v]){
            if(nv.li < w)continue;
            if(chmin(d[nv.to], d[v]+1))que.push(nv.to);
        }
    }
    return d[n-1];
}
int main() {
    int n, m;
    cin >> n >> m;
    rep(i, m){
        int s, t, d;
        cin >> s >> t >> d;
        s--; t--;
        G[s].push_back({t, d});
        G[t].push_back({s, d});
    }
    ll ok = 0, ng = mod;
    while(ng - ok > 1){
        ll mid = (ng + ok) / 2;
        if(BFS(mid, n) != inf)ok = mid;
        else ng = mid;
    }
    cout << ok << " "<< BFS(ok, n) << endl;
}
0