結果

問題 No.1607 Kth Maximum Card
ユーザー tko919tko919
提出日時 2021-09-20 17:12:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,711 ms / 3,500 ms
コード長 1,337 bytes
コンパイル時間 2,129 ms
コンパイル使用メモリ 209,508 KB
実行使用メモリ 28,100 KB
最終ジャッジ日時 2023-09-15 11:35:12
合計ジャッジ時間 22,229 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1,711 ms
28,100 KB
testcase_09 AC 1,229 ms
23,304 KB
testcase_10 AC 1,574 ms
28,040 KB
testcase_11 AC 270 ms
9,104 KB
testcase_12 AC 1,210 ms
22,272 KB
testcase_13 AC 141 ms
6,696 KB
testcase_14 AC 174 ms
7,944 KB
testcase_15 AC 1,114 ms
21,120 KB
testcase_16 AC 134 ms
6,952 KB
testcase_17 AC 49 ms
4,380 KB
testcase_18 AC 562 ms
15,244 KB
testcase_19 AC 339 ms
10,652 KB
testcase_20 AC 534 ms
12,504 KB
testcase_21 AC 535 ms
13,664 KB
testcase_22 AC 1,466 ms
25,560 KB
testcase_23 AC 1,499 ms
25,668 KB
testcase_24 AC 315 ms
10,252 KB
testcase_25 AC 167 ms
7,792 KB
testcase_26 AC 224 ms
8,852 KB
testcase_27 AC 338 ms
10,456 KB
testcase_28 AC 285 ms
9,248 KB
testcase_29 AC 713 ms
16,304 KB
testcase_30 AC 1,540 ms
24,836 KB
testcase_31 AC 695 ms
15,008 KB
testcase_32 AC 260 ms
13,912 KB
testcase_33 AC 258 ms
14,056 KB
testcase_34 AC 249 ms
14,036 KB
testcase_35 AC 259 ms
13,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
using ll=long long int;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}



int main(){
   int n,m,k;
   cin>>n>>m>>k;
   using P=pair<int,int>;
   vector g(n,vector<P>());
   rep(_,0,m){
      int x,y,c;
      cin>>x>>y>>c;
      x--; y--;
      g[x].push_back({y,c});
      g[y].push_back({x,c});
   }

   int L=0,R=201010;
   while(R-L>1){
      int mid=(L+R)>>1;
      vector h(n,vector<P>());
      rep(i,0,n)for(auto& [to,c]:g[i]){
         if(c<mid){
            h[i].push_back({to,0});
         }
         else{
            h[i].push_back({to,1});
         }
      }
      vector<int> dist(n,inf);
      dist[0]=0;
      priority_queue<P,vector<P>,greater<P>> pq;
      pq.push({0,0});
      while(!pq.empty()){
         auto [d,v]=pq.top();
         pq.pop();
         if(dist[v]!=d)continue;
         for(auto& [to,c]:h[v])if(chmin(dist[to],d+c)){
            pq.push({dist[to],to});
         }
      }
      if(dist[n-1]<=k-1)R=mid;
      else L=mid;
   }
   cout<<L<<'\n';
   return 0;
}
0