結果

問題 No.1473 おでぶなおばけさん
ユーザー NoviNovi
提出日時 2021-04-12 22:02:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,909 bytes
コンパイル時間 4,674 ms
コンパイル使用メモリ 235,304 KB
実行使用メモリ 11,796 KB
最終ジャッジ日時 2023-09-11 03:06:28
合計ジャッジ時間 11,108 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
4,408 KB
testcase_01 AC 4 ms
4,376 KB
testcase_02 AC 181 ms
11,528 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 165 ms
11,144 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 21 ms
5,996 KB
testcase_15 AC 37 ms
8,288 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 9 ms
4,932 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 65 ms
10,756 KB
testcase_23 AC 52 ms
9,752 KB
testcase_24 AC 54 ms
9,752 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 126 ms
10,700 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 81 ms
9,820 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 67 ms
8,664 KB
testcase_37 WA -
testcase_38 AC 18 ms
5,312 KB
testcase_39 WA -
testcase_40 AC 39 ms
7,536 KB
testcase_41 AC 40 ms
6,992 KB
testcase_42 AC 40 ms
6,916 KB
testcase_43 AC 48 ms
9,844 KB
testcase_44 AC 48 ms
9,852 KB
testcase_45 AC 48 ms
9,940 KB
testcase_46 WA -
testcase_47 AC 123 ms
10,500 KB
testcase_48 AC 111 ms
9,680 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
#define int ll
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define ALL(a) (a).begin(), (a).end()
template <class t, class u> void chmax(t& a, u b) {
    if (a < b) a = b;
}
template <class t, class u> void chmin(t& a, u b) {
    if (b < a) a = b;
}
template <class t> using vc = vector<t>;
template <class t> using vvc = vc<vc<t>>;
using pi = pair<int, int>;
using vi = vc<int>;
using uint = unsigned;
using ull = unsigned long long;
int popcount(signed t) { return __builtin_popcount(t); }
int popcount(ll t) { return __builtin_popcountll(t); }
bool ispow2(int i) { return i && (i & -i) == i; }
ll mask(int i) { return (ll(1) << i) - 1; }
int lcm(int a, int b) { return a / __gcd(a, b) * b; }
int n, m;
int cnt = 0;
vc<vc<pi>> G;
int bfs(int w, int st = 0, int dist = 0) {
    vc<int> ch(100100, 1e18);
    ch[st] = dist;
    queue<pi> pq;
    pq.push(pi(st, dist));
    while (!pq.empty()) {
        auto p = pq.front();
        pq.pop();
        auto now = p.first;
        auto d = p.second;
        for (auto u : G[now]) {
            if (ch[u.first] > d + 1 && u.second >= w) {
                ch[u.first] = d + 1;
                pq.push(pi(u.first, d + 1));
            }
        }
    }
    return cnt = ch[n - 1];
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
    cin >> n >> m;
    G.resize(n);
    rep(i, m) {
        int s, t, d;
        cin >> s >> t >> d;
        s--, t--;
        G[s].emplace_back(t, d);
        G[t].emplace_back(s, d);
    }
    int ng = 0LL;
    int ok = 1LL << 60;
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        if (bfs(mid) == 1e18) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    cout << ng << " " << cnt << endl;
}
0