結果

問題 No.1473 おでぶなおばけさん
ユーザー wunderkammer2wunderkammer2
提出日時 2021-06-21 22:00:28
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 165 ms / 2,000 ms
コード長 4,355 bytes
コンパイル時間 1,480 ms
コンパイル使用メモリ 134,080 KB
実行使用メモリ 11,460 KB
最終ジャッジ日時 2023-09-05 01:56:55
合計ジャッジ時間 9,607 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 119 ms
11,180 KB
testcase_03 AC 79 ms
10,176 KB
testcase_04 AC 58 ms
7,616 KB
testcase_05 AC 26 ms
4,788 KB
testcase_06 AC 121 ms
10,588 KB
testcase_07 AC 115 ms
11,460 KB
testcase_08 AC 165 ms
11,432 KB
testcase_09 AC 93 ms
11,424 KB
testcase_10 AC 39 ms
7,284 KB
testcase_11 AC 53 ms
9,088 KB
testcase_12 AC 34 ms
8,072 KB
testcase_13 AC 23 ms
6,252 KB
testcase_14 AC 16 ms
5,528 KB
testcase_15 AC 39 ms
7,680 KB
testcase_16 AC 35 ms
6,768 KB
testcase_17 AC 4 ms
4,380 KB
testcase_18 AC 7 ms
4,380 KB
testcase_19 AC 43 ms
7,452 KB
testcase_20 AC 58 ms
9,428 KB
testcase_21 AC 80 ms
9,316 KB
testcase_22 AC 59 ms
10,288 KB
testcase_23 AC 46 ms
9,400 KB
testcase_24 AC 47 ms
9,472 KB
testcase_25 AC 94 ms
10,264 KB
testcase_26 AC 75 ms
10,508 KB
testcase_27 AC 27 ms
5,836 KB
testcase_28 AC 96 ms
11,332 KB
testcase_29 AC 76 ms
9,228 KB
testcase_30 AC 89 ms
9,848 KB
testcase_31 AC 83 ms
11,324 KB
testcase_32 AC 96 ms
11,048 KB
testcase_33 AC 58 ms
9,392 KB
testcase_34 AC 23 ms
6,228 KB
testcase_35 AC 39 ms
6,832 KB
testcase_36 AC 58 ms
8,132 KB
testcase_37 AC 51 ms
8,996 KB
testcase_38 AC 10 ms
4,392 KB
testcase_39 AC 32 ms
6,824 KB
testcase_40 AC 35 ms
7,000 KB
testcase_41 AC 35 ms
6,580 KB
testcase_42 AC 36 ms
6,516 KB
testcase_43 AC 47 ms
8,676 KB
testcase_44 AC 47 ms
8,728 KB
testcase_45 AC 46 ms
8,868 KB
testcase_46 AC 65 ms
8,868 KB
testcase_47 AC 86 ms
10,136 KB
testcase_48 AC 93 ms
9,724 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<algorithm>     //sort,二分探索,など
#include<bit>           //popcount
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム(標準入力変更用)
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//#include<atcoder\all>
//using namespace atcoder;

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
const int MAXR = 100000;             //10^5:配列の最大のrange

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in1(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define in4(x1, x2, x3, x4) cin >> x1 >> x2 >> x3 >> x4
#define in5(x1, x2, x3, x4, x5) cin >> x1 >> x2 >> x3 >> x4 >> x5
#define in6(x1, x2, x3, x4, x5, x6) cin >> x1 >> x2 >> x3 >> x4 >> x5 >> x6
#define inN(x, N) rep(i, N) in1(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl
#define out3l(x1, x2, x3) cout << x1 << " " << x2 << " " << x3 << endl
#define out4l(x1, x2, x3, x4) cout << x1 << " " << x2 << " " << x3 << " " << x4 << endl
#define outList(x) for(auto y : x) cout << y << " ";cout << endl

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
inline ll div_ceil(ll a, ll b) { return (a + (b - 1)) / b; }
inline string zeropad(int n, int m) { ostringstream sout; sout << setfill('0') << setw(m) << n; return sout.str(); }


class Edge
{
public:
    int to;
    ll cost;

    Edge(int to, ll cost)
    {
        this->to = to;
        this->cost = cost;
    }
};

typedef vector<vector<Edge>> Graph;

Graph G;

int n, m;

ll C(ll w)
{
    int s = 0;
    int t = n - 1;

    vll d(n, INF);

    queue<int> q;
    q.push(s);
    d[s] = 0;

    while (!q.empty())
    {
        auto p = q.front(); q.pop();
        if (p == t) break;

        for (auto e : G[p])
        {
            if (d[e.to] != INF) continue;
            if (e.cost < w) continue;

            q.push(e.to);
            d[e.to] = d[p] + 1;
        }
    }

    return d[t];
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    
    in2(n, m);

    G.resize(n);
    rep(_, m)
    {
        int a, b;
        ll c;
        cin >> a >> b >> c;
        a--;
        b--;
        G[a].emplace_back(b, c);
        G[b].emplace_back(a, c);
    }

    ll lb = 0;
    ll ub = INF;
    ll c = 0;

    while (ub - lb > 1)
    {
        ll mid = (ub + lb) / 2;

        ll tmp = C(mid);

        if (tmp != INF)
        {
            lb = mid;
            c = tmp;
        }
        else
        {
            ub = mid;
        }
    }

    out2l(lb, c);

    return 0;
}
0