結果

問題 No.1473 おでぶなおばけさん
ユーザー m_tsubasam_tsubasa
提出日時 2021-04-09 21:39:10
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 253 ms / 2,000 ms
コード長 879 bytes
コンパイル時間 3,467 ms
コンパイル使用メモリ 209,920 KB
実行使用メモリ 9,960 KB
最終ジャッジ日時 2023-09-07 10:24:02
合計ジャッジ時間 10,836 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 177 ms
9,272 KB
testcase_03 AC 137 ms
8,712 KB
testcase_04 AC 109 ms
6,588 KB
testcase_05 AC 43 ms
4,384 KB
testcase_06 AC 197 ms
8,964 KB
testcase_07 AC 183 ms
9,596 KB
testcase_08 AC 253 ms
9,700 KB
testcase_09 AC 178 ms
9,960 KB
testcase_10 AC 86 ms
5,396 KB
testcase_11 AC 88 ms
6,300 KB
testcase_12 AC 86 ms
5,676 KB
testcase_13 AC 52 ms
4,628 KB
testcase_14 AC 39 ms
4,376 KB
testcase_15 AC 73 ms
5,360 KB
testcase_16 AC 82 ms
5,196 KB
testcase_17 AC 7 ms
4,380 KB
testcase_18 AC 11 ms
4,380 KB
testcase_19 AC 80 ms
5,652 KB
testcase_20 AC 106 ms
8,000 KB
testcase_21 AC 128 ms
6,844 KB
testcase_22 AC 102 ms
8,424 KB
testcase_23 AC 84 ms
8,128 KB
testcase_24 AC 82 ms
7,668 KB
testcase_25 AC 226 ms
8,268 KB
testcase_26 AC 228 ms
8,072 KB
testcase_27 AC 64 ms
4,820 KB
testcase_28 AC 186 ms
9,616 KB
testcase_29 AC 131 ms
6,940 KB
testcase_30 AC 164 ms
7,676 KB
testcase_31 AC 148 ms
9,324 KB
testcase_32 AC 144 ms
9,296 KB
testcase_33 AC 113 ms
7,816 KB
testcase_34 AC 66 ms
5,928 KB
testcase_35 AC 61 ms
5,536 KB
testcase_36 AC 109 ms
6,192 KB
testcase_37 AC 139 ms
7,576 KB
testcase_38 AC 23 ms
4,376 KB
testcase_39 AC 83 ms
5,160 KB
testcase_40 AC 83 ms
5,128 KB
testcase_41 AC 74 ms
4,788 KB
testcase_42 AC 74 ms
4,944 KB
testcase_43 AC 93 ms
7,048 KB
testcase_44 AC 93 ms
6,980 KB
testcase_45 AC 93 ms
6,880 KB
testcase_46 AC 116 ms
7,440 KB
testcase_47 AC 146 ms
8,456 KB
testcase_48 AC 129 ms
8,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using P = pair<int, int>;

int n, m;
vector<vector<P>> g;

int solve(int lim);

int main() {
  cin >> n >> m;
  g.resize(n);
  for (int i = 0; i < m; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    g[--a].emplace_back(--b, c);
    g[b].emplace_back(a, c);
  }
  int l = 0, r = 1e9 + 1;
  while (r - l > 1) {
    int mid = (l + r) >> 1;
    if (solve(mid) < 0)
      r = mid;
    else
      l = mid;
  }
  cout << l << " " << solve(l) << endl;
  return 0;
}

int solve(int lim) {
  vector<int> dist(n, n + 1);
  queue<int> qu;
  dist[0] = 0;
  qu.push(0);
  while (qu.size()) {
    int now = qu.front();
    qu.pop();
    for (auto [to, x] : g[now])
      if (x >= lim && dist[to] > dist[now] + 1) {
        dist[to] = dist[now] + 1;
        qu.push(to);
      }
  }
  if (dist[n - 1] == n + 1) return -1;
  return dist[n - 1];
}
0