結果

問題 No.1473 おでぶなおばけさん
ユーザー chocono2230chocono2230
提出日時 2021-04-09 23:11:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 213 ms / 2,000 ms
コード長 1,391 bytes
コンパイル時間 2,193 ms
コンパイル使用メモリ 210,748 KB
実行使用メモリ 9,556 KB
最終ジャッジ日時 2023-09-07 12:56:49
合計ジャッジ時間 9,662 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 181 ms
9,312 KB
testcase_03 AC 131 ms
8,332 KB
testcase_04 AC 103 ms
6,400 KB
testcase_05 AC 40 ms
4,376 KB
testcase_06 AC 178 ms
8,496 KB
testcase_07 AC 163 ms
9,456 KB
testcase_08 AC 213 ms
9,548 KB
testcase_09 AC 160 ms
9,556 KB
testcase_10 AC 83 ms
5,204 KB
testcase_11 AC 86 ms
6,288 KB
testcase_12 AC 85 ms
5,748 KB
testcase_13 AC 51 ms
4,896 KB
testcase_14 AC 37 ms
4,380 KB
testcase_15 AC 71 ms
5,544 KB
testcase_16 AC 80 ms
5,244 KB
testcase_17 AC 7 ms
4,380 KB
testcase_18 AC 11 ms
4,380 KB
testcase_19 AC 76 ms
5,652 KB
testcase_20 AC 98 ms
7,740 KB
testcase_21 AC 116 ms
6,744 KB
testcase_22 AC 90 ms
8,456 KB
testcase_23 AC 79 ms
7,844 KB
testcase_24 AC 76 ms
7,708 KB
testcase_25 AC 192 ms
8,228 KB
testcase_26 AC 194 ms
7,992 KB
testcase_27 AC 60 ms
4,976 KB
testcase_28 AC 182 ms
9,504 KB
testcase_29 AC 135 ms
7,068 KB
testcase_30 AC 162 ms
7,496 KB
testcase_31 AC 131 ms
9,440 KB
testcase_32 AC 137 ms
8,792 KB
testcase_33 AC 103 ms
7,692 KB
testcase_34 AC 55 ms
5,428 KB
testcase_35 AC 58 ms
5,408 KB
testcase_36 AC 104 ms
6,188 KB
testcase_37 AC 121 ms
7,676 KB
testcase_38 AC 23 ms
4,380 KB
testcase_39 AC 82 ms
4,868 KB
testcase_40 AC 82 ms
4,916 KB
testcase_41 AC 72 ms
4,956 KB
testcase_42 AC 71 ms
4,764 KB
testcase_43 AC 89 ms
7,040 KB
testcase_44 AC 89 ms
6,876 KB
testcase_45 AC 90 ms
6,848 KB
testcase_46 AC 109 ms
7,328 KB
testcase_47 AC 132 ms
8,120 KB
testcase_48 AC 119 ms
7,732 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int fc(const vector<vector<pair<int, int>>> &gr, int mid) {
  int n = gr.size();
  vector<int> chk(n, -1);
  queue<int> q;
  chk.at(0) = 0; q.push(0);
  while(!q.empty()) {
    auto now = q.front(); q.pop();
    for(auto [nx, c] : gr.at(now)) {
      if(c < mid) continue;
      if(chk.at(nx) != -1) continue;
      chk.at(nx) = chk.at(now) + 1;
      q.push(nx);
    }
  }
  return chk.back();
}

int main() {
  int n, m;
  cin >> n >> m;
  vector gr(n, vector<pair<int, int>>());
  rep(i, m) {
    int s, t, d;
    cin >> s >> t >> d;
    s--; t--;
    gr.at(s).push_back({t, d});
    gr.at(t).push_back({s, d});
  }
  int ok = 0, ng = 1001001001;
  int ans = 0;
  while(ng - ok > 1) {
    int mid = (ok+ng)/2;
    int r = fc(gr, mid);
    // cerr << r << " " << mid << endl;
    if(r != -1) {
      ok = mid;
      ans = r;
    } else ng = mid;
  }
  cout << ok << " " << ans << endl;
  return 0;
}
0