結果

問題 No.1607 Kth Maximum Card
ユーザー 👑 NachiaNachia
提出日時 2021-07-16 22:25:19
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,199 bytes
コンパイル時間 791 ms
コンパイル使用メモリ 84,388 KB
実行使用メモリ 16,608 KB
最終ジャッジ日時 2023-09-20 14:40:06
合計ジャッジ時間 7,149 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 WA -
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 WA -
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 453 ms
16,388 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 39 ms
4,744 KB
testcase_14 AC 47 ms
5,756 KB
testcase_15 AC 266 ms
12,768 KB
testcase_16 WA -
testcase_17 AC 14 ms
4,376 KB
testcase_18 AC 145 ms
9,572 KB
testcase_19 AC 88 ms
7,276 KB
testcase_20 AC 121 ms
8,156 KB
testcase_21 AC 134 ms
8,580 KB
testcase_22 AC 347 ms
15,480 KB
testcase_23 AC 332 ms
15,392 KB
testcase_24 AC 100 ms
7,092 KB
testcase_25 AC 63 ms
5,664 KB
testcase_26 AC 72 ms
6,144 KB
testcase_27 AC 102 ms
7,092 KB
testcase_28 AC 83 ms
6,500 KB
testcase_29 WA -
testcase_30 AC 484 ms
15,036 KB
testcase_31 AC 156 ms
9,752 KB
testcase_32 AC 73 ms
8,632 KB
testcase_33 AC 74 ms
8,880 KB
testcase_34 AC 73 ms
8,416 KB
testcase_35 AC 74 ms
8,420 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// Nachia くんだよ

#include <iostream>
#include <vector>
#include <deque>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

struct Edge{ int v,c; };

int N,M,K;
vector<vector<Edge>> E;

bool solve(int v){
  vector<int> D(N,1001001);
  vector<int> F(N,0);
  D[0] = 0;
  deque<int> I;
  I.push_back(0);
  while(I.size()){
    int p = I.back(); I.pop_back();
    if(F[p]) continue;
    F[p] = 1;
    for(auto e : E[p]){
      if(e.c <= v){
        if(D[e.v] <= D[p]) continue;
        D[e.v] = D[p];
        I.push_back(e.v);
      }
      else{
        if(D[e.v] <= D[p] + 1) continue;
        D[e.v] = D[p] + 1;
        I.push_front(e.v);
      }
    }
  }
  return D[N-1] < K;
}

int main() {
  cin >> N >> M >> K;
  E.resize(N);
  rep(i,M){
    int u,v,c; cin >> u >> v >> c; u--; v--;
    E[u].push_back({v,c});
    E[v].push_back({u,c});
  }
  
  int l=0, r=200001;
  while(r-l > 1){
    int m = (l+r) / 2;
    if(solve(m)) r = m;
    else l = m;
  }
  cout << r << "\n";
  return 0;
}


struct ios_do_not_sync{
  ios_do_not_sync(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
  }
} ios_do_not_sync_instance;


0