結果
問題 | No.2387 Yokan Factory |
ユーザー |
![]() |
提出日時 | 2023-07-21 23:10:17 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 942 ms / 5,000 ms |
コード長 | 1,743 bytes |
コンパイル時間 | 1,855 ms |
コンパイル使用メモリ | 179,244 KB |
実行使用メモリ | 19,332 KB |
最終ジャッジ日時 | 2024-09-22 00:40:44 |
合計ジャッジ時間 | 11,131 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 |
コンパイルメッセージ
main.cpp: In function 'bool dijkstra(std::vector<std::vector<std::pair<long long int, std::pair<long long int, long long int> > > >&, ll)': main.cpp:44:24: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions] 44 | for(auto&& [p,q]:g[y]){ | ^
ソースコード
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++) #define rrep(i,a,b) for(ll i=(ll)(a-1);i>=(ll)(b);i--) #define MOD 998244353 #define INF 1e16 template <typename T> bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;} template <typename T> bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;} ll comb(ll x,ll y){ ll ans=1; rep(i,0,y) ans*=(x-i); rep(i,0,y) ans/=(i+1); return ans; } ll rui(ll x){ if(x==0) return 1; return 2*rui(x-1); } ll fac(ll x){ if(x==0) return 1; return x*fac(x-1); } ll pow(ll x,ll n){ ll ans=1; while(n>0){ if(n&1) ans*=x; x*=x; n>>=1; } return ans; } ll n,m,x; vector<vector<pair<ll,pair<ll,ll>>>> g; bool dijkstra(vector<vector<pair<ll,pair<ll,ll>>>>& g,ll h){ vector<ll> d(n,1e18); priority_queue<pair<ll,pair<ll,ll>>,vector<pair<ll,pair<ll,ll>>>,greater<pair<ll,pair<ll,ll>>>> pq; pq.push({0,{0,1e18}}); while(!pq.empty()){ ll x=pq.top().first,y=pq.top().second.first,z=pq.top().second.second; if(d[y]>x){ d[y]=x; for(auto&& [p,q]:g[y]){ if(q.second<h) continue; pq.push({q.first+x,{p,q.second}}); } } pq.pop(); } return d[n-1]<=x; } int main(){ cin >> n >> m >> x; vector<ll> u(m),v(m),a(m),b(m); g.resize(n); rep(i,0,m){ cin >> u[i] >> v[i] >> a[i] >> b[i]; u[i]--,v[i]--; g[u[i]].push_back({v[i],{a[i],b[i]}}); g[v[i]].push_back({u[i],{a[i],b[i]}}); } ll p=-1,q=1e9; while(q-p>1){ ll r=(p+q)/2; if(dijkstra(g,r)) p=r; else q=r; } cout << p << endl; }