結果

問題 No.1607 Kth Maximum Card
ユーザー 👑 tute7627tute7627
提出日時 2021-04-09 18:21:27
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 892 ms / 3,500 ms
コード長 1,013 bytes
コンパイル時間 2,185 ms
コンパイル使用メモリ 209,096 KB
実行使用メモリ 15,724 KB
最終ジャッジ日時 2023-09-20 12:26:53
合計ジャッジ時間 13,233 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 573 ms
15,724 KB
testcase_09 AC 377 ms
13,276 KB
testcase_10 AC 585 ms
15,720 KB
testcase_11 AC 73 ms
6,268 KB
testcase_12 AC 391 ms
12,868 KB
testcase_13 AC 53 ms
4,840 KB
testcase_14 AC 69 ms
5,336 KB
testcase_15 AC 361 ms
12,236 KB
testcase_16 AC 57 ms
4,804 KB
testcase_17 AC 19 ms
4,380 KB
testcase_18 AC 200 ms
9,192 KB
testcase_19 AC 124 ms
7,028 KB
testcase_20 AC 175 ms
7,708 KB
testcase_21 AC 188 ms
8,516 KB
testcase_22 AC 633 ms
14,816 KB
testcase_23 AC 698 ms
14,756 KB
testcase_24 AC 145 ms
6,924 KB
testcase_25 AC 85 ms
5,536 KB
testcase_26 AC 106 ms
6,008 KB
testcase_27 AC 148 ms
7,076 KB
testcase_28 AC 118 ms
6,264 KB
testcase_29 AC 276 ms
9,964 KB
testcase_30 AC 892 ms
14,288 KB
testcase_31 AC 275 ms
9,292 KB
testcase_32 AC 155 ms
8,628 KB
testcase_33 AC 154 ms
8,900 KB
testcase_34 AC 154 ms
8,712 KB
testcase_35 AC 154 ms
8,708 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});
  }

  int ok = 300000, ng = -1;
  while(ok - ng >= 2){
    int mid = (ok + ng) / 2;
    deque<int>deq;
    vector<int>dist(n, 1e9);
    vector<bool>used(n);
    dist[0] = 0;
    deq.push_back(0);
    while(!deq.empty()){
      auto v = deq.front();
      deq.pop_front();
      if(used[v])continue;
      used[v] = true;
      for(auto e:g[v]){
        if(e.c > mid){
          if(dist[e.to] > dist[v] + 1){
            deq.push_back(e.to);
            dist[e.to] = dist[v] + 1;
          }
        }
        else if(dist[e.to] > dist[v]){
          deq.push_front(e.to);
          dist[e.to] = dist[v];
        }
      }
    }

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

  cout << ok << endl;
}
0