結果

問題 No.1607 Kth Maximum Card
ユーザー たたき@競プロたたき@競プロ
提出日時 2023-09-01 05:27:24
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 736 ms / 3,500 ms
コード長 1,006 bytes
コンパイル時間 5,881 ms
コンパイル使用メモリ 314,652 KB
実行使用メモリ 15,772 KB
最終ジャッジ日時 2023-09-01 05:27:43
合計ジャッジ時間 17,064 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 499 ms
15,772 KB
testcase_09 AC 277 ms
13,264 KB
testcase_10 AC 360 ms
15,692 KB
testcase_11 AC 71 ms
5,916 KB
testcase_12 AC 287 ms
12,928 KB
testcase_13 AC 52 ms
4,988 KB
testcase_14 AC 69 ms
5,628 KB
testcase_15 AC 297 ms
12,320 KB
testcase_16 AC 57 ms
4,896 KB
testcase_17 AC 18 ms
4,380 KB
testcase_18 AC 199 ms
9,476 KB
testcase_19 AC 125 ms
7,008 KB
testcase_20 AC 185 ms
7,908 KB
testcase_21 AC 185 ms
8,680 KB
testcase_22 AC 472 ms
14,796 KB
testcase_23 AC 490 ms
14,832 KB
testcase_24 AC 135 ms
6,752 KB
testcase_25 AC 80 ms
5,508 KB
testcase_26 AC 97 ms
6,056 KB
testcase_27 AC 141 ms
7,032 KB
testcase_28 AC 115 ms
6,496 KB
testcase_29 AC 254 ms
9,948 KB
testcase_30 AC 736 ms
14,340 KB
testcase_31 AC 260 ms
9,332 KB
testcase_32 AC 154 ms
8,796 KB
testcase_33 AC 161 ms
8,884 KB
testcase_34 AC 151 ms
8,636 KB
testcase_35 AC 151 ms
8,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using mint=modint998244353; //1000000007;
using ll=long long;
using pp=pair<int,int>;
#define sr string 
#define vc vector
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define pque priority_queue
#define bpc(a) __builtin_popcount(a)
int main(){
  int n,m,k;cin>>n>>m>>k;
  vc v(n,vc<pp>(0));
  rep(i,m){
    int a,b,c;cin>>a>>b>>c;
    a--;b--;
    v[a].pb({b,c}); v[b].pb({a,c});
  }
  ll wa=-1,ac=1e6;
  while(ac-wa>1){
    int x=(ac+wa)/2;
    vc<int>d(n,k+1); d[0]=0;
    deque<int>q; q.push_back(0);
    while(q.size()){
      int a=q.front(); q.pop_front();
      for(auto [au,c]:v[a]){
        if(c>x)c=1;
        else c=0;
        if(d[au]<=d[a]+c)continue;
        d[au]=d[a]+c;
        if(c)q.push_back(au);
        else q.push_front(au);
      }
    }
    if(d[n-1]<k)ac=x;
    else wa=x;
  }
  cout<<ac;
}
        
0