結果
問題 |
No.1607 Kth Maximum Card
|
ユーザー |
![]() |
提出日時 | 2023-09-01 05:27:24 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 554 ms / 3,500 ms |
コード長 | 1,006 bytes |
コンパイル時間 | 5,755 ms |
コンパイル使用メモリ | 333,400 KB |
実行使用メモリ | 15,788 KB |
最終ジャッジ日時 | 2025-01-03 06:16:56 |
合計ジャッジ時間 | 14,832 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 33 |
ソースコード
#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; }