結果

問題 No.1473 おでぶなおばけさん
ユーザー だれだれ
提出日時 2021-04-09 21:34:24
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 205 ms / 2,000 ms
コード長 2,408 bytes
コンパイル時間 3,799 ms
コンパイル使用メモリ 185,652 KB
実行使用メモリ 9,568 KB
最終ジャッジ日時 2023-09-07 10:11:15
合計ジャッジ時間 10,532 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 154 ms
9,364 KB
testcase_03 AC 127 ms
8,368 KB
testcase_04 AC 99 ms
6,584 KB
testcase_05 AC 39 ms
4,380 KB
testcase_06 AC 172 ms
8,536 KB
testcase_07 AC 160 ms
9,452 KB
testcase_08 AC 198 ms
9,436 KB
testcase_09 AC 149 ms
9,568 KB
testcase_10 AC 84 ms
5,320 KB
testcase_11 AC 86 ms
6,312 KB
testcase_12 AC 84 ms
6,032 KB
testcase_13 AC 50 ms
4,628 KB
testcase_14 AC 37 ms
4,376 KB
testcase_15 AC 71 ms
5,420 KB
testcase_16 AC 82 ms
5,308 KB
testcase_17 AC 7 ms
4,376 KB
testcase_18 AC 11 ms
4,380 KB
testcase_19 AC 75 ms
5,680 KB
testcase_20 AC 95 ms
7,780 KB
testcase_21 AC 116 ms
6,880 KB
testcase_22 AC 91 ms
8,372 KB
testcase_23 AC 73 ms
7,912 KB
testcase_24 AC 73 ms
7,776 KB
testcase_25 AC 200 ms
8,396 KB
testcase_26 AC 205 ms
8,108 KB
testcase_27 AC 61 ms
4,756 KB
testcase_28 AC 169 ms
9,356 KB
testcase_29 AC 122 ms
7,024 KB
testcase_30 AC 153 ms
7,548 KB
testcase_31 AC 138 ms
9,380 KB
testcase_32 AC 130 ms
8,768 KB
testcase_33 AC 103 ms
7,664 KB
testcase_34 AC 55 ms
5,580 KB
testcase_35 AC 58 ms
5,416 KB
testcase_36 AC 101 ms
6,256 KB
testcase_37 AC 123 ms
7,740 KB
testcase_38 AC 22 ms
4,380 KB
testcase_39 AC 81 ms
5,060 KB
testcase_40 AC 82 ms
5,068 KB
testcase_41 AC 71 ms
4,956 KB
testcase_42 AC 72 ms
5,200 KB
testcase_43 AC 91 ms
7,108 KB
testcase_44 AC 90 ms
7,008 KB
testcase_45 AC 90 ms
6,900 KB
testcase_46 AC 105 ms
7,268 KB
testcase_47 AC 126 ms
8,332 KB
testcase_48 AC 121 ms
7,924 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <unordered_set>
using namespace std;
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i, n) _rep2(i, 0, n)
#define _rep2(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using i64 = long long;
template<class T, class U>
bool chmin(T& a, const U& b) { return (b < a) ? (a = b, true) : false; }
template<class T, class U>
bool chmax(T& a, const U& b) { return (b > a) ? (a = b, true) : false; }

template<typename T>istream& operator>>(istream&i,vector<T>&v){rep(j,v.size())i>>v[j];return i;}
template<typename T>string join(vector<T>&v){stringstream s;rep(i,v.size())s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v){if(v.size())o<<join(v);return o;}
template<typename T>string join(vector<vector<T>>&vv){string s="\n";rep(i,vv.size())s+=join(vv[i])+"\n";return s;}
template<typename T>ostream& operator<<(ostream&o,vector<vector<T>>&vv){if(vv.size())o<<join(vv);return o;}

int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<pair<int, int>>> edge(n);
    rep(i, m)
    {
        int s, t, d;
        cin >> s >> t >> d;
        s--, t--;
        edge[s].emplace_back(t, d);
        edge[t].emplace_back(s, d);
    }
    int ans = 1e9;
    int ok = 0, ng = 1e9 + 1;
    while(ng - ok > 1)
    {
        int mid = (ok + ng) / 2;
        queue<int> que;
        que.push(0);
        vector<int> visited(n, -1);
        visited[0] = 0;
        while(!que.empty())
        {
            auto now = que.front();
            que.pop();
            for (auto [e, d]: edge[now])
            {
                if (d < mid) continue;
                if (visited[e] != -1) continue;
                visited[e] = visited[now] + 1;
                que.push(e);
            }
        }
        if (visited[n - 1] == -1) ng = mid;
        else
        {
            ok = mid;
            ans = visited[n - 1];
        }
    }
    cout << ok << " " << ans << endl;
}
0