結果

問題 No.1607 Kth Maximum Card
ユーザー 👑 tute7627tute7627
提出日時 2021-04-09 18:35:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,250 ms / 3,500 ms
コード長 895 bytes
コンパイル時間 2,073 ms
コンパイル使用メモリ 209,360 KB
実行使用メモリ 16,004 KB
最終ジャッジ日時 2023-09-20 12:27:11
合計ジャッジ時間 15,364 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1,250 ms
15,984 KB
testcase_09 AC 946 ms
13,864 KB
testcase_10 AC 1,243 ms
16,004 KB
testcase_11 AC 196 ms
5,956 KB
testcase_12 AC 918 ms
13,380 KB
testcase_13 AC 67 ms
5,004 KB
testcase_14 AC 79 ms
5,488 KB
testcase_15 AC 456 ms
12,388 KB
testcase_16 AC 70 ms
5,000 KB
testcase_17 AC 27 ms
4,380 KB
testcase_18 AC 250 ms
9,308 KB
testcase_19 AC 155 ms
7,004 KB
testcase_20 AC 256 ms
7,916 KB
testcase_21 AC 251 ms
8,560 KB
testcase_22 AC 581 ms
14,744 KB
testcase_23 AC 625 ms
14,700 KB
testcase_24 AC 167 ms
6,664 KB
testcase_25 AC 93 ms
5,348 KB
testcase_26 AC 109 ms
5,876 KB
testcase_27 AC 161 ms
6,944 KB
testcase_28 AC 130 ms
6,320 KB
testcase_29 AC 398 ms
9,848 KB
testcase_30 AC 966 ms
14,380 KB
testcase_31 AC 387 ms
9,364 KB
testcase_32 AC 154 ms
9,104 KB
testcase_33 AC 151 ms
8,744 KB
testcase_34 AC 153 ms
8,840 KB
testcase_35 AC 152 ms
8,892 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

struct edge{
  int to;
  int c;
};

int main(){
  int n, m, k;
  cin >> n >> m >> k;
  
  vector<vector<edge>>g(n);
  for(int i = 0; i < m; i++){
    int u, v, c;
    cin >> u >> v >> c;
    u--, v--;
    g[u].push_back({v, c});
    g[v].push_back({u, c});
  }

  using pi = pair<int, int>;
  int ok = 300000, ng = -1;
  while(ok - ng >= 2){
    int mid = (ok + ng) / 2;
    priority_queue<pi, vector<pi>, greater<pi>>que;
    vector<int>dist(n, 1e9);
    dist[0] = 0;
    que.emplace(0, 0);
    while(!que.empty()){
      auto [d, v] = que.top();
      que.pop();
      if(dist[v] != d)continue;
      for(auto e:g[v]){
        int nd = d + (e.c > mid);
        if(dist[e.to] > nd){
          dist[e.to] = nd;
          que.emplace(nd, e.to);
        }
      }
    }

    if(dist[n - 1] < k)ok = mid;
    else ng = mid;
  }

  cout << ok << endl;
}
0