結果
問題 | No.2387 Yokan Factory |
ユーザー |
|
提出日時 | 2023-07-21 21:37:28 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 570 ms / 5,000 ms |
コード長 | 2,100 bytes |
コンパイル時間 | 1,915 ms |
コンパイル使用メモリ | 209,848 KB |
最終ジャッジ日時 | 2025-02-15 16:33:25 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 |
ソースコード
#include <bits/stdc++.h>#include <variant>#define rep2(i, k, n) for (i64 i = (i64)(k); i < (i64)(n); i++)#define rep(i, n) rep2(i, 0, n)#define all(x) begin(x), end(x)#ifdef ENV_LOCAL#define dump \if (1) cerr#else#define dump \if (0) cerr#endifusing namespace std;using namespace std::string_literals;using i32 = int32_t;using i64 = int64_t;using f64 = double;using f80 = long double;using vi32 = vector<i32>;using vi64 = vector<i64>;// using namespace harudake;using Weight = i64;Weight INF = 2e18;struct Edge {int src, dest;Weight weight;bool operator<(const Edge &rhs) const { return weight > rhs.weight; }};using Edges = vector<Edge>;using Graph = vector<Edges>;using Array = vector<Weight>;using Matrix = vector<Array>;void add_edge(Graph &g, int src, int dest, Weight weight) {g[src].push_back((Edge){src, dest, weight});g[dest].push_back((Edge){dest, src, weight});}// Dijkstra (Verified: AOJ2005)void dijkstra(Graph &g, Array &d, int s) {d.assign(g.size(), INF);d[s] = 0;using P = pair<Weight, int>;priority_queue<P, vector<P>, greater<P>> que;que.push(P(0, s));while (!que.empty()) {Weight dist = que.top().first;int v = que.top().second;que.pop();if (d[v] < dist) continue;rep(i, g[v].size()) {Edge e = g[v][i];if (d[e.dest] > d[v] + e.weight) {d[e.dest] = d[v] + e.weight;que.push(P(d[e.dest], e.dest));}}}}int main() {ios::sync_with_stdio(false);cin.tie(nullptr);i64 n, m, x;cin >> n >> m >> x;vector<tuple<i64, i64, i64, i64>> edges;rep(i, m) {i64 u, v, a, b;cin >> u >> v >> a >> b;--u;--v;edges.emplace_back(u, v, a, b);}i64 le = -1, gt = 1e9 + 1;while (gt - le > 1) {i64 mid = (gt + le) / 2;Graph g(n);for (auto &&[u, v, a, b] : edges) {if (b < mid) continue;add_edge(g, u, v, a);}Array dist(n);dijkstra(g, dist, 0);if (dist[n - 1] <= x) {le = mid;} else {gt = mid;}}cout << le << endl;return 0;}