結果

問題 No.1473 おでぶなおばけさん
ユーザー hiro71687khiro71687k
提出日時 2023-03-02 06:32:55
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,329 bytes
コンパイル時間 6,166 ms
コンパイル使用メモリ 269,700 KB
実行使用メモリ 12,524 KB
最終ジャッジ日時 2023-10-17 05:00:53
合計ジャッジ時間 18,421 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 154 ms
12,260 KB
testcase_03 AC 145 ms
11,256 KB
testcase_04 AC 72 ms
8,300 KB
testcase_05 AC 31 ms
5,176 KB
testcase_06 AC 166 ms
11,868 KB
testcase_07 AC 139 ms
12,524 KB
testcase_08 AC 142 ms
12,524 KB
testcase_09 AC 138 ms
12,524 KB
testcase_10 AC 94 ms
7,660 KB
testcase_11 AC 95 ms
9,092 KB
testcase_12 AC 95 ms
8,300 KB
testcase_13 AC 57 ms
6,448 KB
testcase_14 AC 42 ms
5,556 KB
testcase_15 AC 78 ms
7,808 KB
testcase_16 AC 91 ms
6,980 KB
testcase_17 AC 8 ms
4,348 KB
testcase_18 AC 13 ms
4,348 KB
testcase_19 AC 83 ms
8,188 KB
testcase_20 AC 115 ms
10,464 KB
testcase_21 AC 115 ms
10,256 KB
testcase_22 AC 102 ms
11,204 KB
testcase_23 AC 84 ms
10,148 KB
testcase_24 AC 83 ms
10,140 KB
testcase_25 AC 124 ms
10,940 KB
testcase_26 AC 133 ms
11,256 KB
testcase_27 AC 50 ms
6,272 KB
testcase_28 AC 146 ms
12,260 KB
testcase_29 AC 123 ms
9,936 KB
testcase_30 AC 150 ms
10,992 KB
testcase_31 AC 137 ms
12,260 KB
testcase_32 AC 160 ms
12,048 KB
testcase_33 AC 109 ms
10,200 KB
testcase_34 AC 52 ms
7,032 KB
testcase_35 AC 64 ms
7,468 KB
testcase_36 AC 91 ms
8,564 KB
testcase_37 AC 93 ms
9,620 KB
testcase_38 AC 21 ms
4,780 KB
testcase_39 AC 91 ms
6,980 KB
testcase_40 AC 91 ms
6,980 KB
testcase_41 AC 77 ms
6,656 KB
testcase_42 AC 77 ms
6,656 KB
testcase_43 TLE -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
using ld=long double;
ld pie=3.14159265359;
ll inf=80010010000000000;
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;
    queue<ll>que;
    vector<ll>memo2(n,0);
    que.push(0);
    memo2[0]=inf;
    while (!que.empty())
    {
        ll v=que.front();
        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(g[v][i].first);
            }
        }
    }
    que.push(0);
    while (!que.empty())
    {
        ll v=que.front();
        que.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;
                que.push(g[v][i].first);
            }
        }
    }
    cout << memo2[n-1] << ' '<< memo[n-1] << endl;
}
0