結果

問題 No.1607 Kth Maximum Card
ユーザー SSRSSSRS
提出日時 2021-07-16 21:39:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 925 ms / 3,500 ms
コード長 964 bytes
コンパイル時間 1,669 ms
コンパイル使用メモリ 174,756 KB
実行使用メモリ 16,308 KB
最終ジャッジ日時 2023-09-20 13:22:23
合計ジャッジ時間 11,555 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 651 ms
15,912 KB
testcase_09 AC 398 ms
13,540 KB
testcase_10 AC 518 ms
16,308 KB
testcase_11 AC 84 ms
6,368 KB
testcase_12 AC 377 ms
13,244 KB
testcase_13 AC 59 ms
4,852 KB
testcase_14 AC 74 ms
5,528 KB
testcase_15 AC 435 ms
12,264 KB
testcase_16 AC 63 ms
4,908 KB
testcase_17 AC 21 ms
4,376 KB
testcase_18 AC 234 ms
9,164 KB
testcase_19 AC 137 ms
6,756 KB
testcase_20 AC 203 ms
7,840 KB
testcase_21 AC 214 ms
8,516 KB
testcase_22 AC 668 ms
14,932 KB
testcase_23 AC 670 ms
14,788 KB
testcase_24 AC 146 ms
6,820 KB
testcase_25 AC 87 ms
5,460 KB
testcase_26 AC 105 ms
6,056 KB
testcase_27 AC 183 ms
7,128 KB
testcase_28 AC 135 ms
6,168 KB
testcase_29 AC 250 ms
9,952 KB
testcase_30 AC 925 ms
14,364 KB
testcase_31 AC 270 ms
9,428 KB
testcase_32 AC 200 ms
11,512 KB
testcase_33 AC 203 ms
11,576 KB
testcase_34 AC 203 ms
11,492 KB
testcase_35 AC 204 ms
11,640 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M, K;
  cin >> N >> M >> K;
  vector<vector<pair<int, int>>> E(N);
  for (int i = 0; i < M; i++){
    int u, v, c;
    cin >> u >> v >> c;
    u--;
    v--;
    E[u].push_back(make_pair(c, v));
    E[v].push_back(make_pair(c, u));
  }
  int tv = 200000, fv = -1;
  while (tv - fv > 1){
    int mid = (tv + fv) / 2;
    vector<int> d(N, -1);
    deque<pair<int, int>> dq;
    dq.push_back(make_pair(0, 0));
    while (!dq.empty()){
      int dd = dq.front().first;
      int v = dq.front().second;
      dq.pop_front();
      if (d[v] == -1){
        d[v] = dd;
        for (auto P : E[v]){
          int w = P.second;
          if (P.first > mid){
            dq.push_back(make_pair(dd + 1, w));
          } else {
            dq.push_front(make_pair(dd, w));
          }
        }
      }
    }
    if (d[N - 1] < K){
      tv = mid;
    } else {
      fv = mid;
    }
  }
  cout << tv << endl;
}
0