結果

問題 No.1473 おでぶなおばけさん
ユーザー yataro800yataro800
提出日時 2023-01-10 21:21:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 260 ms / 2,000 ms
コード長 1,592 bytes
コンパイル時間 4,923 ms
コンパイル使用メモリ 233,740 KB
実行使用メモリ 11,604 KB
最終ジャッジ日時 2023-08-23 10:20:30
合計ジャッジ時間 14,212 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 187 ms
11,260 KB
testcase_03 AC 145 ms
10,248 KB
testcase_04 AC 110 ms
7,692 KB
testcase_05 AC 43 ms
4,632 KB
testcase_06 AC 196 ms
10,612 KB
testcase_07 AC 183 ms
11,604 KB
testcase_08 AC 240 ms
11,476 KB
testcase_09 AC 169 ms
11,456 KB
testcase_10 AC 90 ms
7,384 KB
testcase_11 AC 92 ms
8,844 KB
testcase_12 AC 91 ms
8,164 KB
testcase_13 AC 53 ms
6,108 KB
testcase_14 AC 39 ms
5,408 KB
testcase_15 AC 77 ms
7,632 KB
testcase_16 AC 86 ms
6,708 KB
testcase_17 AC 8 ms
4,376 KB
testcase_18 AC 11 ms
4,376 KB
testcase_19 AC 84 ms
7,568 KB
testcase_20 AC 109 ms
9,396 KB
testcase_21 AC 131 ms
9,312 KB
testcase_22 AC 107 ms
10,364 KB
testcase_23 AC 86 ms
9,424 KB
testcase_24 AC 87 ms
9,392 KB
testcase_25 AC 254 ms
10,264 KB
testcase_26 AC 260 ms
10,444 KB
testcase_27 AC 67 ms
5,860 KB
testcase_28 AC 213 ms
11,396 KB
testcase_29 AC 144 ms
9,232 KB
testcase_30 AC 187 ms
9,996 KB
testcase_31 AC 163 ms
11,324 KB
testcase_32 AC 157 ms
10,820 KB
testcase_33 AC 117 ms
9,308 KB
testcase_34 AC 61 ms
6,436 KB
testcase_35 AC 65 ms
6,696 KB
testcase_36 AC 113 ms
8,200 KB
testcase_37 AC 139 ms
8,988 KB
testcase_38 AC 23 ms
4,396 KB
testcase_39 AC 88 ms
6,904 KB
testcase_40 AC 87 ms
6,732 KB
testcase_41 AC 77 ms
6,516 KB
testcase_42 AC 76 ms
6,448 KB
testcase_43 AC 95 ms
8,924 KB
testcase_44 AC 95 ms
8,776 KB
testcase_45 AC 94 ms
8,708 KB
testcase_46 AC 126 ms
8,952 KB
testcase_47 AC 164 ms
10,140 KB
testcase_48 AC 148 ms
9,620 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <math.h>

#include <algorithm>
#include <array>
#include <atcoder/all>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <vector>

using namespace std;
using namespace atcoder;

using Graph = vector<vector<int>>;

using ll = long long;
typedef pair<ll, ll> P_ll;
typedef pair<int, int> P;

const ll INF_ll = 1e17;
const int INF = 1e8;
template <class T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<P_ll>> G(n);
  for (int 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});
  }
  ll ok = 0;
  ll ng = 1e9 + 1;
  ll ans = -1;
  while (ng - ok > 1) {
    ll mid = (ok + ng) / 2;
    vector<ll> d(n, -1);
    d[0] = 0;
    queue<int> q;
    q.push(0);
    while (!q.empty()) {
      auto u = q.front();
      q.pop();
      for (auto e : G[u]) {
        if (e.second < mid) {
          continue;
        }
        int next = e.first;
        if (d[next] >= 0) {
          continue;
        }
        d[next] = d[u] + 1;
        q.push(next);
      }
    }
    if (d[n - 1] >= 0) {
      ok = mid;
      ans = d[n - 1];
    } else {
      ng = mid;
    }
  }
  cout << ok << " " << ans << endl;

  return 0;
}
0