結果

問題 No.1473 おでぶなおばけさん
ユーザー hiro71687khiro71687k
提出日時 2023-03-02 06:33:57
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,316 bytes
コンパイル時間 5,521 ms
コンパイル使用メモリ 268,848 KB
実行使用メモリ 10,168 KB
最終ジャッジ日時 2023-10-17 05:01:47
合計ジャッジ時間 14,352 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 134 ms
9,904 KB
testcase_03 AC 129 ms
9,164 KB
testcase_04 AC 66 ms
7,000 KB
testcase_05 AC 28 ms
4,624 KB
testcase_06 AC 146 ms
9,112 KB
testcase_07 AC 123 ms
10,168 KB
testcase_08 AC 126 ms
10,168 KB
testcase_09 AC 123 ms
10,168 KB
testcase_10 AC 91 ms
5,416 KB
testcase_11 AC 91 ms
6,588 KB
testcase_12 AC 91 ms
6,028 KB
testcase_13 AC 54 ms
4,892 KB
testcase_14 AC 40 ms
4,360 KB
testcase_15 AC 76 ms
5,680 KB
testcase_16 AC 89 ms
5,152 KB
testcase_17 AC 8 ms
4,348 KB
testcase_18 AC 13 ms
4,348 KB
testcase_19 AC 79 ms
6,260 KB
testcase_20 AC 112 ms
8,320 KB
testcase_21 AC 110 ms
7,316 KB
testcase_22 AC 93 ms
8,848 KB
testcase_23 AC 78 ms
8,320 KB
testcase_24 AC 77 ms
8,056 KB
testcase_25 AC 113 ms
8,628 KB
testcase_26 AC 120 ms
8,900 KB
testcase_27 AC 50 ms
5,108 KB
testcase_28 AC 136 ms
9,904 KB
testcase_29 AC 112 ms
7,608 KB
testcase_30 AC 136 ms
8,372 KB
testcase_31 AC 119 ms
9,904 KB
testcase_32 AC 142 ms
9,428 KB
testcase_33 AC 101 ms
8,124 KB
testcase_34 AC 50 ms
5,996 KB
testcase_35 AC 61 ms
5,988 KB
testcase_36 AC 89 ms
6,472 KB
testcase_37 AC 89 ms
8,056 KB
testcase_38 AC 20 ms
4,356 KB
testcase_39 AC 89 ms
5,152 KB
testcase_40 AC 90 ms
5,152 KB
testcase_41 AC 76 ms
5,124 KB
testcase_42 AC 77 ms
5,124 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=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;
    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