結果
問題 | No.2387 Yokan Factory |
ユーザー |
|
提出日時 | 2023-07-22 15:55:00 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 378 ms / 5,000 ms |
コード長 | 1,411 bytes |
コンパイル時間 | 2,916 ms |
コンパイル使用メモリ | 167,936 KB |
最終ジャッジ日時 | 2025-02-15 18:02:00 |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 |
ソースコード
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <utility> #include <map> #include <set> #include <queue> #include <iomanip> #include <cstring> #include <atcoder/all> using namespace std; using namespace atcoder; typedef long long ll; #define rep(i,n) for (int i = 0; i < int(n);i++) int main(){ int n,m; ll x; cin >> n >> m >> x; vector<vector<pair<pair<int,ll>,ll>>> g(n); for (int i = 0; i < m;i++){ int u,v; ll a,b; cin >> u >> v >> a >> b; g[v-1].push_back({{u-1,a},b}); g[u-1].push_back({{v-1,a},b}); } ll ok = -1,ng = 1e18+1LL; const ll INF = 1LL << 60; while(ng-ok > 1LL){ ll mid = (ok+ng)/2; vector<ll> dist(n,INF); dist[0] = 0; priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>> que; que.push({0,0}); while(!que.empty()){ auto [d,x] = que.top(); que.pop(); if (d > dist[x]) continue; for (auto [a,b]:g[x]){ if (a.second +dist[x] <= dist[a.first] && b >= mid){ dist[a.first] = dist[x]+a.second; que.push({dist[a.first],a.first}); } } } //cout << mid << endl; //for (auto e:dist){ // if (e >= INF) cout << "F" << " "; // else cout << e << " "; //} //cout << endl; if (dist[n-1] <= x){ ok = mid; } else{ ng = mid; } } cout << ok << endl; return 0; }