結果

問題 No.1607 Kth Maximum Card
ユーザー fumofumofunifumofumofuni
提出日時 2021-07-21 20:59:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 963 ms / 3,500 ms
コード長 1,607 bytes
コンパイル時間 2,291 ms
コンパイル使用メモリ 209,916 KB
実行使用メモリ 19,480 KB
最終ジャッジ日時 2023-09-24 13:28:04
合計ジャッジ時間 12,747 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 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,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 693 ms
19,276 KB
testcase_09 AC 494 ms
16,264 KB
testcase_10 AC 731 ms
19,480 KB
testcase_11 AC 73 ms
6,776 KB
testcase_12 AC 484 ms
15,540 KB
testcase_13 AC 57 ms
5,516 KB
testcase_14 AC 74 ms
6,512 KB
testcase_15 AC 409 ms
16,072 KB
testcase_16 AC 60 ms
6,140 KB
testcase_17 AC 20 ms
4,380 KB
testcase_18 AC 218 ms
11,992 KB
testcase_19 AC 132 ms
8,968 KB
testcase_20 AC 194 ms
10,156 KB
testcase_21 AC 209 ms
11,012 KB
testcase_22 AC 709 ms
18,528 KB
testcase_23 AC 753 ms
18,536 KB
testcase_24 AC 168 ms
8,352 KB
testcase_25 AC 91 ms
6,664 KB
testcase_26 AC 110 ms
7,084 KB
testcase_27 AC 189 ms
8,616 KB
testcase_28 AC 129 ms
7,616 KB
testcase_29 AC 387 ms
12,872 KB
testcase_30 AC 963 ms
19,076 KB
testcase_31 AC 306 ms
12,240 KB
testcase_32 AC 172 ms
13,284 KB
testcase_33 AC 173 ms
13,456 KB
testcase_34 AC 171 ms
13,456 KB
testcase_35 AC 171 ms
13,320 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=(n)-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={-1,0,1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template <typename T> inline bool chmax(T &a, T b) {
  return ((a < b) ? (a = b, true) : (false));
}
template <typename T> inline bool chmin(T &a, T b) {
  return ((a > b) ? (a = b, true) : (false));
}

int main(){
  ll n,m,k;cin >> n >> m >>k;
  vvpl g(n);
  rep(i,m){
    ll a,b,c;cin >> a >> b >> c;a--;b--;
    g[a].push_back({b,c});
    g[b].push_back({a,c});
  }
  ll ok=1e5*3,ng=-1;
  while(ok-ng>1){
    ll mid=(ok+ng)/2;
    vl dist(n,inf);dist[0]=0;
    deque<ll> que;que.push_back(0);
    while(!que.empty()){
      ll v=que.front();que.pop_front();
      for(auto p:g[v]){
        if(p.se<=mid){
          if(chmin(dist[p.fi],dist[v]))que.push_front(p.fi);
        }
        else{
          if(chmin(dist[p.fi],dist[v]+1))que.push_back(p.fi);
        }
      }
    }
    if(dist[n-1]<k)ok=mid;
    else ng=mid;
  }
  cout << ok <<endl;
}   
0