結果

問題 No.1473 おでぶなおばけさん
ユーザー hiro71687khiro71687k
提出日時 2023-03-02 06:38:01
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 409 ms / 2,000 ms
コード長 1,391 bytes
コンパイル時間 5,950 ms
コンパイル使用メモリ 270,456 KB
実行使用メモリ 11,328 KB
最終ジャッジ日時 2023-10-17 05:05:27
合計ジャッジ時間 12,968 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 253 ms
10,444 KB
testcase_03 AC 305 ms
9,924 KB
testcase_04 AC 102 ms
7,004 KB
testcase_05 AC 53 ms
4,956 KB
testcase_06 AC 296 ms
10,072 KB
testcase_07 AC 137 ms
10,172 KB
testcase_08 AC 145 ms
10,172 KB
testcase_09 AC 143 ms
10,172 KB
testcase_10 AC 98 ms
5,776 KB
testcase_11 AC 94 ms
6,644 KB
testcase_12 AC 95 ms
6,136 KB
testcase_13 AC 55 ms
4,896 KB
testcase_14 AC 41 ms
4,364 KB
testcase_15 AC 76 ms
5,684 KB
testcase_16 AC 89 ms
5,620 KB
testcase_17 AC 8 ms
4,348 KB
testcase_18 AC 13 ms
4,348 KB
testcase_19 AC 175 ms
7,992 KB
testcase_20 AC 240 ms
9,268 KB
testcase_21 AC 227 ms
9,156 KB
testcase_22 AC 109 ms
9,116 KB
testcase_23 AC 89 ms
8,324 KB
testcase_24 AC 86 ms
8,324 KB
testcase_25 AC 126 ms
9,036 KB
testcase_26 AC 132 ms
9,032 KB
testcase_27 AC 51 ms
5,200 KB
testcase_28 AC 159 ms
9,908 KB
testcase_29 AC 206 ms
9,504 KB
testcase_30 AC 237 ms
11,100 KB
testcase_31 AC 128 ms
9,908 KB
testcase_32 AC 409 ms
11,328 KB
testcase_33 AC 246 ms
10,148 KB
testcase_34 AC 93 ms
6,456 KB
testcase_35 AC 120 ms
6,708 KB
testcase_36 AC 93 ms
6,792 KB
testcase_37 AC 100 ms
8,060 KB
testcase_38 AC 20 ms
4,404 KB
testcase_39 AC 92 ms
5,428 KB
testcase_40 AC 94 ms
5,468 KB
testcase_41 AC 76 ms
5,128 KB
testcase_42 AC 77 ms
5,128 KB
testcase_43 AC 106 ms
8,268 KB
testcase_44 AC 105 ms
8,268 KB
testcase_45 AC 105 ms
8,268 KB
testcase_46 AC 94 ms
7,796 KB
testcase_47 AC 118 ms
8,588 KB
testcase_48 AC 103 ms
8,096 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=int;
using ld=long double;
ld pie=3.14159265359;
ll inf=1000000001;
ll mod=1000000007;
int main(){
    ll n,m;
    cin >> n >> m;
    vector<vector<pair<ll,ll>>>g(n);
    for (ll i = 0; i < m; i++)
    {
        ll s,t,d;
        cin >> s >> t >> d;
        s--,t--;
        g[s].push_back({t,d});
        g[t].push_back({s,d});
    }
    vector<ll>memo(n,inf);
    memo[0]=0;
    priority_queue<pair<ll,ll>>que;
    vector<ll>memo2(n,0);
    que.push({inf,0});
    memo2[0]=inf;
    while (!que.empty())
    {
        ll v=que.top().second;
        que.pop();
        for (ll i = 0; i < g[v].size(); i++)
        {
            if (memo2[g[v][i].first]<min(memo2[v],g[v][i].second))
            {
                memo2[g[v][i].first]=min(memo2[v],g[v][i].second);
                que.push({memo[g[v][i].first],g[v][i].first});
            }
        }
    }
    queue<ll>que2;
    que2.push(0);
    while (!que2.empty())
    {
        ll v=que2.front();
        que2.pop();
        for (ll i = 0; i < g[v].size(); i++)
        {
            if (memo[g[v][i].first]>memo[v]+1&&g[v][i].second>=memo2[n-1])
            {
                memo[g[v][i].first]=memo[v]+1;
                que2.push(g[v][i].first);
            }
        }
    }
    cout << memo2[n-1] << ' '<< memo[n-1] << endl;
}
0