結果
| 問題 |
No.2387 Yokan Factory
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-07-21 21:42:48 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 989 ms / 5,000 ms |
| コード長 | 1,294 bytes |
| コンパイル時間 | 6,137 ms |
| コンパイル使用メモリ | 260,436 KB |
| 最終ジャッジ日時 | 2025-02-15 16:40:20 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 35 |
ソースコード
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll = long long;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using vl = vector<ll>;
using vvl = vector<vl>;
using P = pair<ll,ll>;
#define pb push_back
#define int long long
#define double long double
#define INF (ll) 3e18
// Ctrl + Shift + B コンパイル
// Ctrl + C 中断
// ./m 実行
signed main(){
int n, m, x;
cin >> n >> m >> x;
vector<vector<tuple<int,int,int>>> E(n);
rep(i,m){
int u, v, a, b;
cin >> u >> v >> a >> b;
u--;
v--;
E[u].emplace_back(v, a, b);
E[v].emplace_back(u, a, b);
}
int ok = -1;
int ng = INF;
while(ng - ok != 1){
int mid = (ng + ok) / 2;
vl dist(n, INF);
dist[0] = 0;
priority_queue<P, vector<P>, greater<P>> pq;
pq.emplace(0, 0);
while(pq.size()){
auto [cost, now] = pq.top(); pq.pop();
if (dist[now] != cost) continue;
for(auto [to, a, b] : E[now]){
if (b >= mid){
if (dist[to] <= dist[now] + a) continue;
dist[to] = dist[now] + a;
pq.emplace(dist[to], to);
}
}
}
// cout << dist[n] << " " << mid << endl;
if (dist[n-1] <= x) ok = mid;
else ng = mid;
}
cout << ok << endl;
}