結果
問題 | No.1607 Kth Maximum Card |
ユーザー | fumofumofuni |
提出日時 | 2021-07-21 20:58:10 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 1,352 ms / 3,500 ms |
コード長 | 1,605 bytes |
コンパイル時間 | 2,436 ms |
コンパイル使用メモリ | 207,940 KB |
実行使用メモリ | 19,320 KB |
最終ジャッジ日時 | 2023-09-24 13:27:51 |
合計ジャッジ時間 | 15,947 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,376 KB |
testcase_02 | AC | 2 ms
4,376 KB |
testcase_03 | AC | 2 ms
4,380 KB |
testcase_04 | AC | 2 ms
4,376 KB |
testcase_05 | AC | 1 ms
4,380 KB |
testcase_06 | AC | 2 ms
4,380 KB |
testcase_07 | AC | 2 ms
4,376 KB |
testcase_08 | AC | 979 ms
19,092 KB |
testcase_09 | AC | 679 ms
16,180 KB |
testcase_10 | AC | 1,001 ms
19,060 KB |
testcase_11 | AC | 88 ms
6,860 KB |
testcase_12 | AC | 663 ms
15,644 KB |
testcase_13 | AC | 66 ms
5,832 KB |
testcase_14 | AC | 85 ms
6,508 KB |
testcase_15 | AC | 493 ms
16,188 KB |
testcase_16 | AC | 70 ms
6,000 KB |
testcase_17 | AC | 22 ms
4,376 KB |
testcase_18 | AC | 272 ms
12,336 KB |
testcase_19 | AC | 161 ms
9,016 KB |
testcase_20 | AC | 234 ms
10,416 KB |
testcase_21 | AC | 254 ms
11,196 KB |
testcase_22 | AC | 1,029 ms
18,484 KB |
testcase_23 | AC | 1,034 ms
18,736 KB |
testcase_24 | AC | 224 ms
8,300 KB |
testcase_25 | AC | 117 ms
6,428 KB |
testcase_26 | AC | 153 ms
7,168 KB |
testcase_27 | AC | 231 ms
8,536 KB |
testcase_28 | AC | 186 ms
7,464 KB |
testcase_29 | AC | 567 ms
12,956 KB |
testcase_30 | AC | 1,352 ms
19,320 KB |
testcase_31 | AC | 469 ms
12,040 KB |
testcase_32 | AC | 178 ms
13,272 KB |
testcase_33 | AC | 177 ms
13,452 KB |
testcase_34 | AC | 176 ms
13,380 KB |
testcase_35 | AC | 177 ms
13,376 KB |
ソースコード
#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=inf,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; }