結果
問題 | No.2387 Yokan Factory |
ユーザー | umimel |
提出日時 | 2023-07-21 21:51:24 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 429 ms / 5,000 ms |
コード長 | 2,476 bytes |
コンパイル時間 | 2,042 ms |
コンパイル使用メモリ | 179,544 KB |
実行使用メモリ | 13,312 KB |
最終ジャッジ日時 | 2024-09-21 23:19:25 |
合計ジャッジ時間 | 6,092 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | AC | 2 ms
5,376 KB |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 2 ms
5,376 KB |
testcase_12 | AC | 2 ms
5,376 KB |
testcase_13 | AC | 2 ms
5,376 KB |
testcase_14 | AC | 2 ms
5,376 KB |
testcase_15 | AC | 210 ms
13,308 KB |
testcase_16 | AC | 123 ms
13,312 KB |
testcase_17 | AC | 331 ms
12,128 KB |
testcase_18 | AC | 374 ms
11,008 KB |
testcase_19 | AC | 273 ms
8,824 KB |
testcase_20 | AC | 219 ms
8,448 KB |
testcase_21 | AC | 429 ms
10,604 KB |
testcase_22 | AC | 181 ms
7,808 KB |
testcase_23 | AC | 270 ms
8,892 KB |
testcase_24 | AC | 99 ms
8,276 KB |
testcase_25 | AC | 27 ms
6,400 KB |
testcase_26 | AC | 55 ms
9,600 KB |
testcase_27 | AC | 63 ms
10,240 KB |
testcase_28 | AC | 4 ms
5,376 KB |
testcase_29 | AC | 4 ms
5,376 KB |
testcase_30 | AC | 4 ms
5,376 KB |
testcase_31 | AC | 3 ms
5,376 KB |
testcase_32 | AC | 2 ms
5,376 KB |
testcase_33 | AC | 3 ms
5,376 KB |
testcase_34 | AC | 4 ms
5,376 KB |
testcase_35 | AC | 3 ms
5,376 KB |
testcase_36 | AC | 3 ms
5,376 KB |
testcase_37 | AC | 2 ms
5,376 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; using pll = pair<ll, ll>; #define drep(i, cc, n) for (ll i = (cc); i <= (n); ++i) #define rep(i, n) drep(i, 0, n - 1) #define all(a) (a).begin(), (a).end() #define pb push_back #define fi first #define se second mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count()); const ll MOD1000000007 = 1000000007; const ll MOD998244353 = 998244353; const ll MOD[3] = {999727999, 1070777777, 1000000007}; const ll LINF = 1LL << 60; const int IINF = (1 << 30) - 1; template<typename T> struct Edge{ int to; T w; T b; Edge(int to_, T w_, T b_){ to = to_; w=w_; b=b_; } }; template<typename T> using Tree = vector<vector<Edge<T>>>; template<typename T> using Graph = vector<vector<Edge<T>>>; int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); ll n, m, x; cin >> n >> m >> x; Graph<ll> G(n); rep(i, m){ ll u, v, a, b; cin >> u >> v >> a >> b; u--; v--; G[u].pb(Edge<ll>(v, a, b)); G[v].pb(Edge<ll>(u, a, b)); } //輸送可能チェック { vector<ll> dist(n, LINF); dist[0] = 0; priority_queue<pll, vector<pll>, greater<pll>> PQ; PQ.push({0, 0}); while(!PQ.empty()){ ll v = PQ.top().se; ll tmp = PQ.top().fi; PQ.pop(); if(dist[v] < tmp) continue; for(Edge<ll> e : G[v]){ if(dist[v]+e.w < dist[e.to]){ dist[e.to] = dist[v] + e.w; PQ.push({dist[e.to], e.to}); } } } if(dist[n-1]>x){ cout << -1 << endl; return 0; } } ll low = 0; ll high = 1e9+1; ll mid; while(high-low>1){ mid = (low + high)/2; vector<ll> dist(n, LINF); dist[0] = 0; priority_queue<pll, vector<pll>, greater<pll>> PQ; PQ.push({0, 0}); while(!PQ.empty()){ ll v = PQ.top().se; ll tmp = PQ.top().fi; PQ.pop(); if(dist[v] < tmp) continue; for(Edge<ll> e : G[v]){ if(dist[v]+e.w<dist[e.to] && mid<=e.b){ dist[e.to] = dist[v] + e.w; PQ.push({dist[e.to], e.to}); } } } if(dist[n-1]<=x) low = mid; else high = mid; } cout << low << endl; }