結果

問題 No.1473 おでぶなおばけさん
ユーザー nemutainemutai
提出日時 2023-03-26 10:43:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 509 ms / 2,000 ms
コード長 1,637 bytes
コンパイル時間 3,612 ms
コンパイル使用メモリ 177,500 KB
実行使用メモリ 11,832 KB
最終ジャッジ日時 2023-10-19 13:26:56
合計ジャッジ時間 12,098 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 386 ms
11,612 KB
testcase_03 AC 177 ms
10,432 KB
testcase_04 AC 235 ms
7,748 KB
testcase_05 AC 89 ms
5,004 KB
testcase_06 AC 343 ms
11,120 KB
testcase_07 AC 313 ms
11,832 KB
testcase_08 AC 509 ms
11,832 KB
testcase_09 AC 297 ms
11,832 KB
testcase_10 AC 96 ms
7,636 KB
testcase_11 AC 97 ms
9,068 KB
testcase_12 AC 93 ms
8,460 KB
testcase_13 AC 57 ms
6,424 KB
testcase_14 AC 43 ms
5,532 KB
testcase_15 AC 80 ms
7,784 KB
testcase_16 AC 90 ms
6,956 KB
testcase_17 AC 8 ms
4,348 KB
testcase_18 AC 13 ms
4,348 KB
testcase_19 AC 115 ms
7,936 KB
testcase_20 AC 145 ms
9,668 KB
testcase_21 AC 193 ms
9,684 KB
testcase_22 AC 131 ms
11,092 KB
testcase_23 AC 109 ms
9,620 KB
testcase_24 AC 111 ms
9,784 KB
testcase_25 AC 417 ms
10,664 KB
testcase_26 AC 402 ms
11,368 KB
testcase_27 AC 90 ms
6,280 KB
testcase_28 AC 346 ms
11,708 KB
testcase_29 AC 214 ms
10,088 KB
testcase_30 AC 243 ms
10,996 KB
testcase_31 AC 254 ms
11,648 KB
testcase_32 AC 211 ms
11,360 KB
testcase_33 AC 204 ms
9,636 KB
testcase_34 AC 83 ms
6,660 KB
testcase_35 AC 86 ms
7,068 KB
testcase_36 AC 181 ms
8,732 KB
testcase_37 AC 373 ms
9,260 KB
testcase_38 AC 35 ms
4,776 KB
testcase_39 AC 91 ms
6,956 KB
testcase_40 AC 89 ms
6,956 KB
testcase_41 AC 82 ms
6,632 KB
testcase_42 AC 83 ms
6,632 KB
testcase_43 AC 185 ms
10,580 KB
testcase_44 AC 185 ms
10,580 KB
testcase_45 AC 187 ms
10,580 KB
testcase_46 AC 119 ms
9,068 KB
testcase_47 AC 155 ms
10,360 KB
testcase_48 AC 156 ms
9,820 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define all(v) v.begin(),v.end()
using ll = long long;
using ull = unsigned long long;
using vll=vector<ll>;
using vvll = vector<vector<ll>>;
const ll INF=1ll<<60;
using P = pair<ll,ll>;

int main(){
    ll N,M;
    cin>>N>>M;
    vector<vector<P>> ab(N);
    for(int i=0;i<M;i++){
        ll a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        ab[a].push_back({c,b});
        ab[b].push_back({c,a});
    }
    ll l=0,r=1e16;
    while(r-l>1){
        ll m=(r+l)/2;
        vector<ll> dist(N,INF);
        priority_queue<P,vector<P>,greater<P>> q;
        q.push({0,0});
        dist[0]=0;
        while(!q.empty()){
            auto x=q.top();q.pop();
            ll cost=x.first,now=x.second;
            if(dist[now]<cost)continue;
            for(auto x2:ab[now]){
                ll tcost=x2.first,to=x2.second;
                if(tcost<m)continue;
                if(dist[to]<=dist[now]+1)continue;
                dist[to]=dist[now]+1;
                q.push({dist[to],to});
            }
        }
        if(dist[N-1]!=INF) l=m;
        else r=m;
    }
    ll m=l;
    vector<ll> dist(N,INF);
    priority_queue<P,vector<P>,greater<P>> q;
    q.push({0,0});
    dist[0]=0;
    while(!q.empty()){
        auto x=q.top();q.pop();
        ll cost=x.first,now=x.second;
        if(dist[now]<cost)continue;
        for(auto x2:ab[now]){
            ll tcost=x2.first,to=x2.second;
            if(tcost<m)continue;
            if(dist[to]<=dist[now]+1)continue;
            dist[to]=dist[now]+1;
            q.push({dist[to],to});
        }
    }
    cout << l<<" "<<dist[N-1]<< endl;
}
0